1. 防火墙必须配置为允许1433端口为引入端口,以及1024-65535为外出端口 2. 连接字符串必须指定SQL Server地址:IP地址,服务器DNS名字或host文件里的名字 3. 连接字符串应当指定Network Library类型,在这种情况下"dbmssocn" (没有引号)为TCP/IP Sockets Net-Library在下面的例子代码中, servername应当为服务器DNS名字, IP 地址,或hosts文件中的名字: Set Conn = CreateObject("ADODB.Connection") Set Rs = CreateObject("ADODB.Recordset")Set Cmd = Createobject("ADODB.Command") Conn.Open "Provider=SQLOLEDB;Password=password;Persist Security Info=True;UserID=username; _ Initial Catalog=DBNAME;Data Source=servername;Network Library=dbmssocn" Cmd.ActiveConnection=Conn SQL = "Select * from TABLE" Cmd.CommandText = SQL Set Rs = Cmd.Execute |
|站长邮箱|小黑屋|手机版|Office中国/Access中国
( 粤ICP备10043721号-1 )
GMT+8, 2025-4-4 05:12 , Processed in 0.066211 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.