我的过程如下:
1.安装了mysql 运行都没问题 
2.安装vb
3.新建个工程  标准 exe
4.添加个 Command1
里面内容如下:
Public server As String
Public user As String
Public password As String
Public ConnStr As String
Public scon As ADODB.Connection
Public rs As ADODB.RecordsetPrivate Sub Command1_Click()Dim strconnectionstring As String
user = root
password = 123456
Private Sub Form_Load()
          Set scon = New ADODB.Connection
          strconnectionstring = "Provider=SQLOLEDB.1;User ID=user;Password=password;Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=Shop;Data Source=127.0.0.1"
          scon.ConnectionTimeout = 1
          scon.CursorLocation = adUseClient
          scon.ConnectionString = strconnectionstring
          scon.Open
          If scon.State = 1 Then
                  MsgBox "ok"
          Else
                  Err.Clear
                  MsgBox "No"
          End If
  
           
End Sub
运行后出错
提示错误信息如下:
实时错误‘-2147467259 (80004005)';
[DBNETLIB]{ConnectionOpen (Connect()).}SQL Server 不存在或拒绝访问我的数据库名是yzy 
ip 127.0.0.1
id root
密码是 123456请问应该如何去写然后搜索数据库 
得到数据呢?
谢谢各位

解决方案 »

  1.   

    strconnectionstring = "Provider=SQLOLEDB.1;User ID=user;Password=password;Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=Shop;Data Source=127.0.0.1"
    改为:
    strconnectionstring = "Provider=SQLOLEDB.1;User ID=" & user&";Password="& password &";Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=Shop;Data Source=127.0.0.1"
                        
      

  2.   


    strconnectionstring = "Provider=SQLOLEDB.1;User ID=root;Password=123456;Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=yzy;Data Source=127.0.0.1"谢谢回答 我这样写的还是提示那个错误行数在
    scon.Open 这
      

  3.   

    只是安装了mysql数据库没有安装这个 是不可以的吧?ODBC CONNECTER/mysql
      

  4.   

    如果连接语句没问题的话,检查一下SQL的服务管理器启动了没?
      

  5.   

    问题解决了就是没安装 ODBC CONNECTER/mysql驱动!