I am trying to connect to a MySql db that isn't local. I have the following code that looks right but gives me the following error:
Run-time error '-2147467259 (8004005)':
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
Here is my code that I have in a command click:
Dim adoCon As ADODB.Connection
Dim adoRs As ADODB.Recordset
Dim strCon As String
Dim strSQL As String
strCon = "Driver={mySQL};" & _
"Server=something.com;" & _
"Port=3306;" & _
"Option=131072;" & _
"Stmt=;" & _
"Database=db_name;" & _
"Uid=name;" & _
"Pwd=pwd;"
Set adoCon = New ADODB.Connection
With adoCon
.ConnectionString = strCon
.Open
End With
Set adoRs = New ADODB.Recordset
strSQL = "SELECT * " _
& " FROM table;"
With adoRs
.CursorLocation = adUseClient
.ActiveConnection = adoCon
.Open strSQL
End With
Do While adoRs.EOF = False
MsgBox adoRs.Fields("Model"
& " " & adoRs.Fields("Brand"
adoRs.MoveNext
Loop
adoRs.Close
Set adoRs = Nothing
adoCon.Close
Set adoCon = Nothing
..............
I also do have a reference to Microsoft ActiveX Data Object 2.5 Library.
I was able to create a DSN on my machine which does allow it to work but I want to be able to distribute this to a few other people. So DSN-less would be much better.
If anyone can give me some advice that would be great.
Thanks.
Run-time error '-2147467259 (8004005)':
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
Here is my code that I have in a command click:
Dim adoCon As ADODB.Connection
Dim adoRs As ADODB.Recordset
Dim strCon As String
Dim strSQL As String
strCon = "Driver={mySQL};" & _
"Server=something.com;" & _
"Port=3306;" & _
"Option=131072;" & _
"Stmt=;" & _
"Database=db_name;" & _
"Uid=name;" & _
"Pwd=pwd;"
Set adoCon = New ADODB.Connection
With adoCon
.ConnectionString = strCon
.Open
End With
Set adoRs = New ADODB.Recordset
strSQL = "SELECT * " _
& " FROM table;"
With adoRs
.CursorLocation = adUseClient
.ActiveConnection = adoCon
.Open strSQL
End With
Do While adoRs.EOF = False
MsgBox adoRs.Fields("Model"
adoRs.MoveNext
Loop
adoRs.Close
Set adoRs = Nothing
adoCon.Close
Set adoCon = Nothing
..............
I also do have a reference to Microsoft ActiveX Data Object 2.5 Library.
I was able to create a DSN on my machine which does allow it to work but I want to be able to distribute this to a few other people. So DSN-less would be much better.
If anyone can give me some advice that would be great.
Thanks.