Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You just need a connection string appropriate to your database, see
http://www.carlprothman.net/Default.aspx?tabid=81 What exactly do you mean by the second part? -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... thanks bob! but I have no Microsoft.Jet.OLEDB.4.0 and one more thing do i have to add an active x control (im reffering to ADO). pls. reply. thanks again. "Bob Phillips" wrote: Using ADO. Here are some examples using an Access database Sub AddData() Dim oConn As Object Dim oRS As Object Dim sSQL As String Set oConn = CreateObject("ADODB.Connection") oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "INSERT INTO Contacts (FirstName, LastName,Phone, Notes) " & _ " VALUES ('Bob','Phillips','01202 345678','me')" oConn.Execute sSQL oConn.Close Set oConn = Nothing End Sub Sub GetData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If Not oRS.EOF Then ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) Else MsgBox "No records returned.", vbCritical End If oRS.Close Set oRS = Nothing End Sub Sub UpdateData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oConn As Object Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If oRS.EOF Then MsgBox "No records returned.", vbCritical Else sSQL = "UPDATE Contacts " & _ " SET Phone = 'None' " & _ "WHERE FirstName = 'Bob' AND LastNAme = 'Phillips'" oRS.ActiveConnection.Execute sSQL sSQL = "SELECT * From Contacts" oRS.ActiveConnection.Execute sSQL ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) End If oRS.Close Set oRS = Nothing End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... Hello! I'm ate ease using SQL statements to manipulate data in a database. But my problem is how can I use it in Excel. Pls. I need everyone's help so badly! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
THanks for the quick reply but I just want to ask if i still want to make a
manual connection like going into control panel then find odbs then blah..blah.. Thanks! "Bob Phillips" wrote: You just need a connection string appropriate to your database, see http://www.carlprothman.net/Default.aspx?tabid=81 What exactly do you mean by the second part? -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... thanks bob! but I have no Microsoft.Jet.OLEDB.4.0 and one more thing do i have to add an active x control (im reffering to ADO). pls. reply. thanks again. "Bob Phillips" wrote: Using ADO. Here are some examples using an Access database Sub AddData() Dim oConn As Object Dim oRS As Object Dim sSQL As String Set oConn = CreateObject("ADODB.Connection") oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "INSERT INTO Contacts (FirstName, LastName,Phone, Notes) " & _ " VALUES ('Bob','Phillips','01202 345678','me')" oConn.Execute sSQL oConn.Close Set oConn = Nothing End Sub Sub GetData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If Not oRS.EOF Then ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) Else MsgBox "No records returned.", vbCritical End If oRS.Close Set oRS = Nothing End Sub Sub UpdateData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oConn As Object Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If oRS.EOF Then MsgBox "No records returned.", vbCritical Else sSQL = "UPDATE Contacts " & _ " SET Phone = 'None' " & _ "WHERE FirstName = 'Bob' AND LastNAme = 'Phillips'" oRS.ActiveConnection.Execute sSQL sSQL = "SELECT * From Contacts" oRS.ActiveConnection.Execute sSQL ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) End If oRS.Close Set oRS = Nothing End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... Hello! I'm ate ease using SQL statements to manipulate data in a database. But my problem is how can I use it in Excel. Pls. I need everyone's help so badly! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Carl has a section on DSN connections.
-- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... THanks for the quick reply but I just want to ask if i still want to make a manual connection like going into control panel then find odbs then blah..blah.. Thanks! "Bob Phillips" wrote: You just need a connection string appropriate to your database, see http://www.carlprothman.net/Default.aspx?tabid=81 What exactly do you mean by the second part? -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... thanks bob! but I have no Microsoft.Jet.OLEDB.4.0 and one more thing do i have to add an active x control (im reffering to ADO). pls. reply. thanks again. "Bob Phillips" wrote: Using ADO. Here are some examples using an Access database Sub AddData() Dim oConn As Object Dim oRS As Object Dim sSQL As String Set oConn = CreateObject("ADODB.Connection") oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "INSERT INTO Contacts (FirstName, LastName,Phone, Notes) " & _ " VALUES ('Bob','Phillips','01202 345678','me')" oConn.Execute sSQL oConn.Close Set oConn = Nothing End Sub Sub GetData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If Not oRS.EOF Then ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) Else MsgBox "No records returned.", vbCritical End If oRS.Close Set oRS = Nothing End Sub Sub UpdateData() Const adOpenForwardOnly As Long = 0 Const adLockReadOnly As Long = 1 Const adCmdText As Long = 1 Dim oConn As Object Dim oRS As Object Dim sConnect As String Dim sSQL As String Dim ary sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & "c:\bob.mdb" sSQL = "SELECT * From Contacts" Set oRS = CreateObject("ADODB.Recordset") oRS.Open sSQL, sConnect, adOpenForwardOnly, _ adLockReadOnly, adCmdText ' Check to make sure we received data. If oRS.EOF Then MsgBox "No records returned.", vbCritical Else sSQL = "UPDATE Contacts " & _ " SET Phone = 'None' " & _ "WHERE FirstName = 'Bob' AND LastNAme = 'Phillips'" oRS.ActiveConnection.Execute sSQL sSQL = "SELECT * From Contacts" oRS.ActiveConnection.Execute sSQL ary = oRS.getrows MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) End If oRS.Close Set oRS = Nothing End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Chinx21" . wrote in message ... Hello! I'm ate ease using SQL statements to manipulate data in a database. But my problem is how can I use it in Excel. Pls. I need everyone's help so badly! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|