下列程序在本机上能运行,在其他机子上不能运行.
Private Sub CommandButton1_Click()
Dim strconnt As String
Dim strSql As String
strconnt = “”
Set connt = New ADODB.Connection
Set rs = New ADODB.Recordset
Dim sevip, Db, user, pwd As String
“”设服务器地址、所连数据,及登录用户密码
sevip = “127.0.0.1”
Db = “pzx”
user = “root”
pwd = “13678096166”
strconnt = “DRIVER={MySql ODBC 5.3 Unicode Driver};SERVER=” & sevip & “;Database=” & Db & “;Uid=” & user & “;Pwd=” & pwd & “;Stmt=set names GBK”
connt.ConnectionString = strconnt
connt.Open
strSql = “select * from info”
rs.Open strSql, connt, 1, 1
Sheets(“sheet1”).Range(“a1”).CopyFromRecordset rs
rs.Close
connt.Close
End Sub
本人的机子在局域网中用固定IP:192.168.0.102 ,当把服务器地址换成192.168.0.102 时,在本机不能运行.
Private Sub CommandButton1_Click()
Dim strconnt As String
Dim strSql As String
strconnt = “”
Set connt = New ADODB.Connection
Set rs = New ADODB.Recordset
Dim sevip, Db, user, pwd As String
“”设服务器地址、所连数据,及登录用户密码
sevip = “192.168.0.102”
Db = “pzx”
user = “root”
pwd = “13678096166”
strconnt = “DRIVER={MySql ODBC 5.3 Unicode Driver};SERVER=” & sevip & “;Database=” & Db & “;Uid=” & user & “;Pwd=” & pwd & “;Stmt=set names GBK”
connt.ConnectionString = strconnt
connt.Open
strSql = “select * from info”
rs.Open strSql, connt, 1, 1
Sheets(“sheet1”).Range(“a1”).CopyFromRecordset rs
rs.Close
connt.Close
End Sub
问一下怎么实现上述访问功能?