ASP连接SQL2000 源码

<%
dim conn
dim connstr
on error resume next
connstr="Driver={SQL Server};Server=192.168.0.10;UID=test;PWD=test1;Database=wawa"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
if conn.State = 1 then
Response.Write "OBJConn 与数据库连接成功"
conn.Close
else
Response.Write "OBJConn 对象的执行过程产生错误!"
end if
Set conn = Nothing
%>
 
或者这样也可以:
<%
On Error Resume NextSet OBJConn = Server.CreateObject("ADODB.Connection")
OBJConn.open "Trade", "test" , "test1"
if OBJConn.State = 1 then
Response.Write "OBJConn 与数据库连接成功"
OBJConn.Close
else
Response.Write "OBJConn 对象的执行过程产生错误!"
end if
Set OBJConn = Nothing
%>

本文出自 “北斗星空” 博客,谢绝转载!

你可能感兴趣的:(sql,数据库,连接,asp,sql2000)