ASP如何显示SQL中的记录

来源:百度知道 编辑:UC知道 时间:2024/06/20 17:31:46
就是把SQL中的全部记录显示到网页中,用ASP代码实现,最简洁的方法!
不好意思,刚开始接触,Order By id DESC是什么意思?

<%@ Page Language="vb" aspcompat=true AutoEventWireup="false"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
dim un
dim pa
dim conn
dim rs
dim sql
un=request.form("user_name")
pa=request.form("password")
conn=Server.CreateObject("ADODB.Connection") '创建一个数据库连接对象conn,方便以后调用
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=QING;UID=sa;PWD=94740;DATABASE=students;")
rs = Server.CreateObject("ADODB.Recordset")
sql ="Select * From student"
RS.open(sql,Conn,1,1)
do while not rs.eof
%>
<%=rs("s_no")%> 列出标题
<%
RS.MoveNext
Loop

<%
database=1
dbuid="sa"
dbpwd="94740"
dbname="students"
dbip=(local)
set conn=Server.CreateObject("adodb.Connection")
Conn.Open "PROVIDER=SQLOLEDB.1;Data Source="&dbip&";Initial Catalog="&dbname&";Persist Security Info=True;User ID="&dbuid&";Password="&dbpwd&";Connect Timeout=30"

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>

 

<table border="0" width="298" id="table1" cellpadding="0" style="border-collapse: collapse" height="45">
<tr>
<td height="22"></td>
</tr>
<%

set rs=se