建议使用ADODB,给你一个连接字符串供参考:
CnStr = "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;uid=" & DbUser & ";pwd=" & DbPw & ";DRIVER=SQL Server;DATABASE=" & DbName & ";WSID=GQSOFT;SERVER=" & DbIP
'也可以使用这段简易代码
CnStr = "Provider=SQLOLEDB;Data Source=" & DbIp & ";DATABASE=" & DbName & ";UID=" & DbUser & ";pwd=" & DbPw
其中:DbIp = "数据库地址"
DbName = "数据库名"
DbUser = "数据操作员用户名"
DbPw = "操作员密码"
具体使用方法去网上查