我的过程如下:
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.安装了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请问应该如何去写然后搜索数据库
得到数据呢?
谢谢各位
改为:
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=root;Password=123456;Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=yzy;Data Source=127.0.0.1"谢谢回答 我这样写的还是提示那个错误行数在
scon.Open 这