<%
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open"select * from blog_content",conn,1,1
if rs.eof and rs.bof then
response.write ("没有数据")
else
response.write ("
")&rs("日志字段名")&(" |
asp读取数据库代码如下:
dim conn,connstr,rs,sql
set conn = Server.CreateObject("Adodb.Connection")
connstr = "Provider=SQLOLEDB;data source=127.0.0.1;initial catalog=DBname;uid=username;pwd=password"
conn.open connstr
set rs = Server.CreateObject("Adodb.RecordSet")
sql = "select id from table"
rs.open sql,conn,1,1
if not rs.eof
response.write "ID为:" & rs("id")
end if
rs.close
conn.close
set conn=nothing
以上代码为把数据库中的id显示出来
ADO