im using:
Function CnnString() As String
Dim strServerName As String
Dim strDatabaseName As String
Dim strUserName As String
Dim strPassword As String
'Change to IP Address if not on local machine
'Make sure that you give permission to log into the
'server from this address
'See Adding New User Accounts to MySQL
'Make sure that you d/l and install the MySQL Connector/ODBC 3.51 Driver
strServerName = "localhost"
strDatabaseName = "DBname"
strUserName = "user"
CnnString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=" & strServerName & _
";DATABASE=" & strDatabaseName & ";" & _
"USER=" & strUserName & _
";PASSWORD=" & strPassword & _
";OPTION=3;"
End Function
as string and:
Dim strSql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open CnnString()
strSql = "<my data source name>"
On Error GoTo Command1_Click_Error
rs.Open strSql, cn
Command1_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Exit Sub
to connect.
yea, its SJ's code...
well, the error i get is
"You have an error in your syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'my data source name'".
i have xampp for mysql and ye, i installed the 3.51 odbc driver
any ideas? :S
thanx in advance
Function CnnString() As String
Dim strServerName As String
Dim strDatabaseName As String
Dim strUserName As String
Dim strPassword As String
'Change to IP Address if not on local machine
'Make sure that you give permission to log into the
'server from this address
'See Adding New User Accounts to MySQL
'Make sure that you d/l and install the MySQL Connector/ODBC 3.51 Driver
strServerName = "localhost"
strDatabaseName = "DBname"
strUserName = "user"
CnnString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=" & strServerName & _
";DATABASE=" & strDatabaseName & ";" & _
"USER=" & strUserName & _
";PASSWORD=" & strPassword & _
";OPTION=3;"
End Function
as string and:
Dim strSql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open CnnString()
strSql = "<my data source name>"
On Error GoTo Command1_Click_Error
rs.Open strSql, cn
Command1_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Exit Sub
to connect.
yea, its SJ's code...
well, the error i get is
"You have an error in your syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'my data source name'".
i have xampp for mysql and ye, i installed the 3.51 odbc driver
any ideas? :S
thanx in advance