SQL Server 2008连接字符串
以VBScript为例,不作复杂的解释:
Set Conn = CreateObject("ADODB.Connection")
本地连接:
Conn.Open("Driver={SQL Server};Server=.\SQLEXPRESS;Database=SJTU;Uid=kissrat;Pwd=kissratpass;")
或者
Conn.Open("Driver={SQL Server};Server=(local)\SQLEXPRESS;Database=SJTU;Uid=kissrat;Pwd=kissratpass;")
通过IP的连接:
必须启用TCP/IP协议和Sql Server Browser服务,并重启Sql Server :
Conn.Open("Driver={SQL Server};Server=127.0.0.1\SQLEXPRESS;Database=SJTU;Uid=kissrat;Pwd=kissratpass;")
Conn.Open("Driver={SQL Server};Server=192.168.0.1\SQLEXPRESS;Database=SJTU;Uid=kissrat;Pwd=kissratpass;")
必要时启用Named Pipes协议。
参考资料: