1、SQL SERVER 字符串直接连接(通常用这种)
<%
dim rs
set rs = server.CreateObject("adodb.recordset")
strDSN = "driver={SQL Server};server=aspx;uid=sa;pwd=;database=pubs;"
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open strDSN
rs.Open "select * from jobs",cn
do while not rs.eof
Response.Write rs("job_id") & "<br>"
rs.MoveNext
loop
%>
2、SQL SERVER DSN直接连接(要配DSN来着)
<%
strDSN = "PROVIDER=MSDASQL;dsn=football;uid=sa;pwd=;database=pubs;"
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open strDSN
dim rs
set rs = server.CreateObject("adodb.recordset")
sql="select * from jobs"
rs.Open sql,cn
while not rs.eof
Response.Write rs("job_desc") & "<br>"
rs.MoveNext
wend
%>