I have this connection string:
Code:
Dim cnnString as String = "Provider=SQLOLEDB;Data Source=myMachineName\SQLEXPRESS;" & _
"Initial Catalog=MyDatabase;" & _
"Integrated Security=SSPI;"
And my code snippet:
Code:
Private Sub adodbQueryBtn_Click()
On Error GoTo dbErrorLbl
Set dbConn = New ADODB.Connection
dbConn.Open cnnString
Set adoRST = dbConn.Execute("SELECT * FROM MyTable;")
dbErrorLbl:
Debug.Print "------------------------------------------------"
Debug.Print "ADODB conn error: " & Err.Number & ", " & Err.Description & ", " & Err.Source & ", " & Err.HelpContext & ", " & Err.HelpFile
End Sub
I keep getting this error:
Code:
ADODB conn error: -2147467259, [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, Microsoft OLE DB Provider for ODBC Drivers, 1000440, C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA7.1\1033\VbLR6.chm
What do I do wrong?