佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1022|回复: 3

connect mysql是出现的error msg

[复制链接]
发表于 22-5-2006 05:24 PM | 显示全部楼层 |阅读模式
为什么会出现以下的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
回复

使用道具 举报


ADVERTISEMENT

发表于 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 还是照旧一样.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-9-2024 05:33 PM , Processed in 0.100310 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表