SQL Server 不存在或拒绝访问。
Microsoft OLE DB Provider for SQL Server (0x***********)[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。/index.asp, 第 29 行数据库<%Dim gym_conngym_conn = "Provider=SQLOLEDB;Server=localhost;Database=gym;UID=sa;PWD=test"%><%dim rs_user,grounfdim rs_user_total,ground_total'打开用户资料数据库---------------Set rs_user = Server.CreateObject("ADODB.Recordset")sql = "SELECT user_name FROM user_reg"rs_user.Open sql,gym_conn,3,2 (29行)'打开场地料数据库---------------Set ground = Server.CreateObject("ADODB.Recordset")sql = "SELECT ground_id FROM dbo.ground"ground.Open sql,gym_conn,3,2
参考答案:尝试使用下面的形式连接数据库
'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、
'连接名(SqlLocalName)(本地用local,外地用IP)
Const SqlDatabaseName = "gym"
Const SqlPassword = "test"
Const SqlUsername = "sa"
Const SqlLocalName = "(local)"
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If