'建立数据库连接
Dim ConnStr, Conn
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath("./user.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
'数据库数据查询
Dim sql, rs
sql = "Select * From info"
Set rs = Server.CreateObject("Adodb.Recordset")
rs.Open sql, Conn, 1, 1
'下面是数据输出
Response.Write("<table width='100%' border='0' cellpadding='0' cellspacing='0'>") &vbCrLf
Response.Write(" <tr>") &vbCrLf
Response.Write("<td height='30'>id</td>") &vbCrLf
Response.Write("<td>username</td>") &vbCrLf
Response.Write("<td>password</td>") &vbCrLf
Response.Write("<td>sex</td>") &vbCrLf
Response.Write("<td>personalinfo</td>") &vbCrLf
Response.Write("<td>ntime</td>") &vbCrLf
Response.Write(" </tr>") &vbCrLf
If rs.BOF And rs.EOF Then
Response.Write("查无数据!")
Else
Do While Not rs.EOF
Response.Write(" <tr>") &vbCrLf
Response.Write("<td height='30'>" &rs("id") &"</td>") &vbCrLf
Response.Write("<td>" &rs("username") &"</td>") &vbCrLf
Response.Write("<td>" &rs("password") &"</td>") &vbCrLf
Response.Write("<td>" &rs("sex") &"</td>") &vbCrLf
Response.Write("<td>" &rs("personalinfo") &"</td>") &vbCrLf
Response.Write("<td>" &rs("ntime") &"</td>") &vbCrLf
Response.Write(" </tr>") &vbCrLf
rs.MoveNext
Loop
End If
Response.Write("</table>") &vbCrLf
'关闭数据库
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
%>
这是全部代码,认真仔细的研究每一句代码,能全部理解的话 那asp基本就等于入门了 加油!:)
写入数据库,肯定要返回到某个页面的,或者直接返回当前页面,这时候在下面接着调用数据库中数据显示出来就行,可以利用?action=view此类的方法BT的问题
用session或cookies保存
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)