第1个回答 2011-12-28
<%
on error resume Next
Set Conn=Server.CreateObject("ADODB.Connection")
Set MyCmd=Server.CreateObject("ADODB.Command")
Conn.ConnectionTimeOut=30
Conn.CommandTimeOut=60
Conn.CursorLocation = 3
Conn.ConnectionString ="Driver={sql server};DataBase=数据库名称;uID=sa;PWD=数据库密码;Server=服务器名称"
Conn.Open
if Conn.state = "0" then
response.write "数据库连接失败,请稍候再试..."&err.description
response.end
end if
Set MyCmd.ActiveConnection=Conn
Set Rs=Server.CreateObject("ADODB.RecordSet")
Str="select * from 随便一个表"
rs.Open Str,Conn
if err<>0 then
Response.write "链路不通,请稍后再试. . . "&err.description
Response.End
end if
rs.close
on error goto 0
%>