Turtleman10
Technical User
I've go this code that I think will get me part way to what I am trying to do but I need to do more. I need to look for a field in a coulumn and it looks like this code will give me everything in the column. cam I correct?
Code:
Sub GetDataFromSQLServer()
Dim conn As Object
Dim recS As Object
Dim strQuery As String
Set conn = CreateObject("ADODB.Connection")
Set recS = CreateObject("ADODB.Recordset")
With conn
.Provider = "sqloledb"
.ConnectionString = "Data Source=CRV43;Initial Catalog=M2MData1;Integrated Security=SSPI;"
.Open
End With
strQuery = "Orders"
recS.Open strQuery, conn
ActiveSheet.Range("A1").CopyFromRecordset (recS)
recS.Close
conn.Close
Set recS = Nothing
Set conn = Nothing
End Sub