asp能与SQL2005连接吗?
大学好,小弟有个问题,就是SQL2005能与asp程序连接吗?如果能连接程序的写法还是一样的吗?
<%
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName,ConnStr,Conn
SqlDatabaseName = "xxx" 'SQL数据库名
SqlUsername = "xxx" 'SQL数据库用户名
SqlPassword = "xxx" 'SQL数据库用户密码
SqlLocalName = "(local)" 'SQL主机IP地址(本地可用“127.0.0.1”或“(local)”,非本机请用真实IP)
ConnStr = "Provider = MSDASQL;DRIVER={SQL Server}; 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
sub CloseConn()
conn.close
set conn=nothing
end sub
%>