On Error GoTo DealErr
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQLdriver={SQL Server}server=122.122.107.56,13000uid=wapwd=gvwsgsgdatabase=reachDb"
ConnectToDataBase=True
MsgBox "连接数据库成功!"
Exit Function
DealErr:
ConnectToDataBase=False
MsgBox "连接数据库失败!"
End
EndFunction
serverstring = "Server=" &服务器IP &"DataBase=" &库名 &"Userid=" &用户名 &"Password=" &密码Try
Conn = New MySqlConnection(serverstring)
Conn.Open()
MsgBox("连接成功")
Conn.Dispose()
Conn.Close()
Catch ex As Exception
MsgBox("连接失败!")
End Try
这是 mysql 的,自己改成 sql server 的就行了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)