<1> : 连接字符串为:
Provider=SQLOLEDB.1;Password=密码;Persist Security Info=True;User ID=用户名;Initial Catalog=数据库名称Data Source=远程主机IP
<2> :
1.引用ADO
2.定义连接Dim Conn as New Connection3.设置连接串Conn.Open "Provider=SQLOLEDB;Data Source=数据库服务器IP或名称;UID=登录用户名;PWD=登录密码;initial catalog=数据库的名称"
<3> : demo program :
Private Sub Timer1_Timer()
Dim ConnX As New ADODB.Connection '生成连接字符串 ConnX.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=jnjw2008;Initial Catalog=tygl;Data Source=192.168.0.119" On Error GoTo ConnErr '连接数据库 ConnX.Open MsgBox "连接数据库成功!服务已启动...", vbInformation, "连接" Exit Sub ConnErr: MsgBox "连接数据库错误!", vbInformation, "连接" End Sub