文章中心 -> 电脑常识

文章正文

绿盟写个数据库连接实例给大家

<%

Set Conn = Server.CreateObject("ADODB.Connection")
SqlDatabaseName = "xdowns.com" 
SqlUsername = "xdowns"         
 SqlPassword = "xdowns.com"           
 SqlLocalName = "218.1.1.1\x"

sqlstr=  "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
 
 

conn.open   sqlstr
Response.Write   "数据库连接成功 "

%>

如果不成功会提示: 

Microsoft OLE DB Provider for SQL Server 错误 '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。

文章来自绿盟(xDowns.com)转载请注明来路。

上一篇文章:sqlserver实例名字怎么连接服务器 []