aps.net 连接 sqlserver 老提示数据库连接出错
<%
DbAddress="localhost" '请输入Sqlserver服务器的IP地址,数据库和推广系统在同一台服务器上只要填写localhost就可以
DbUser="sa" '请输入连接Sqlserver服务器的用户名
DbPassword="cf1234" '请输入连接Sqlserver服务器的密码
DbName="cfwztgsql" '请输入Sqlserver服务器的数据库名称
DbPort="1433" '默认为1433,一般此处不需要更改
PortMap="0" '默认为0,主机是否云主机,0为否,1为是
On Error Resume Next
If DbPort="1433" Then
DbPort=""
Else
DbPort=":"&DbPort
End If
ConnStr="Provider = Sqloledb;Data Source ="&DbAddress&DbPort&";User ID ="&DbUser&";Password ="&DbPassword&";Initial Catalog ="&DbName&";"
Set Conn = Server.CreateObject ("Adodb.Connection")
Conn.Open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
%>
所填写的用户名密码那些全是正确的,本地测试。帮忙看下连接字符串吧,不知哪出错了?
厕所扣大蛆
11 years ago