查看: 1030|回复: 3
|
connect mysql是出现的error msg
[复制链接]
|
|
为什么会出现以下的error msg 呢?
"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
以下是我的connection string:
Dim ConnStr As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=database_abc;" & _
"USER=root;" & _
"PASSWORD=123456;" & _
"OPTION=3;"
Dim MyConn As New OdbcConnection(ConnStr)
Dim Str As String, errormsg As String, InStr As String, InStr2 As String
Dim cmd As New OdbcCommand(Str, MyConn)
Dim cmdreader As OdbcDataReader
Public Function searching() As Boolean
Dim exist As Boolean
Dim errorMSG As String
cmd.CommandText = "select * from test"
Try
MyConn.Open()
cmdreader = cmd.ExecuteReader()
While cmdreader.Read
exist = True
End While
cmdreader.Close()
Catch ex As Exception
errorMSG = ex.Message
Finally
If Not MyConn Is Nothing Then
MyConn.Close()
End If
End Try
Return exist
End Function |
|
|
|
|
|
|
|
发表于 22-5-2006 07:02 PM
|
显示全部楼层
尝试这方法:
1. Control Panel -> Admin Panel -> ODBC
2. System DSN -> MySQL (如果你已经成功安装 MySQL ODBC, 一定会出现)
3. 输入你的 MySQL 资料库的资料...
4. 改一改以下的 code
Dim ConnStr As String = "DSN=" & DSN_名字 & ";UID=" & 用户名字 & "WD=" & 密码
先试试看... |
|
|
|
|
|
|
|
楼主 |
发表于 22-5-2006 11:52 PM
|
显示全部楼层
the problem is becoz i have installed ODBC 5.0 version..
i wondering wat to do if i gonna connect to PC-1's mysql server in PC-2?
how is the connectionstring should be???
if my PC-1's ip address is 192.168.1.2
PC-2's ip address is 192.168.1.3
Dim ConnStr As String = "DSN=TESTING;UID=rootWD=root"
[ 本帖最后由 一只优雅的猪 于 23-5-2006 12:01 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 23-5-2006 12:15 AM
|
显示全部楼层
你在设定 DSN 的时候, 就已经设定了 MySQL 的 IP... 所以你的 connection string 还是照旧一样. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|