ASP查询MSSQL并输出内容 示例源码

<%
set conn=server.CreateObject("ADODB.Connection")
sql="Driver={SQL Server};server=(local);uid=数据库账号;pwd=数据库密码;database=数据库名"
conn.open(sql)

If Err Then
  err.Clear
  Set Conn = Nothing
  Response.Write "数据库连接出错,请检查连接字串。"
  Response.End
 End If

set rs = conn.execute("select * from AgentsData")
do while not rs.eof or bof
response.write rs(0)&","&rs(1)&","&rs(2)&","&rs(3)&","&rs(4)&","&rs(5)&","&rs(7)&","&rs(8)&","&rs(9)&"<br>"
rs.movenext
loop
rs.close

response.write "<br>"&"全部ok鸟~~`"
response.end
%>

发表评论

您的电子邮箱地址不会被公开。