asp 怎么导出从sql中查询的结果?有分页
1个回答
展开全部
1.ASP导出SQL中的查询结果:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<!--#include file="../inc/DBConn.asp"-->
<%
'自行设置的,用于DB Connection连接的函数
Call openConnection()
Dim sql,rs,conn
'SQL语句
sql = " SELECT tbId,tbName from Table"
'执行SQL语句,并将结果赋给RS变量
set rs = Conn.execute(sql)
'对从DB中取得的结果进行操作,当有值时执行以下内容
if Not rs.Eof then
’对结果集进行循环操作,将值输出到画面中
Do while NOT Rs.Eof
response.write(rs("tbId") & "----" & rs("tbName") & "<br>")
rs.MoveNext
Loop
End If
%>
---
call openconnection()是自己做一个加接DB的函数,
dim strConnect
strConnect = "Provider=SQLOLEDB;Data Source=local;Initial Catalog=" testDb;user ID=sa;password=sa;"
Function openConnection()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnect
End Function
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<!--#include file="../inc/DBConn.asp"-->
<%
'自行设置的,用于DB Connection连接的函数
Call openConnection()
Dim sql,rs,conn
'SQL语句
sql = " SELECT tbId,tbName from Table"
'执行SQL语句,并将结果赋给RS变量
set rs = Conn.execute(sql)
'对从DB中取得的结果进行操作,当有值时执行以下内容
if Not rs.Eof then
’对结果集进行循环操作,将值输出到画面中
Do while NOT Rs.Eof
response.write(rs("tbId") & "----" & rs("tbName") & "<br>")
rs.MoveNext
Loop
End If
%>
---
call openconnection()是自己做一个加接DB的函数,
dim strConnect
strConnect = "Provider=SQLOLEDB;Data Source=local;Initial Catalog=" testDb;user ID=sa;password=sa;"
Function openConnection()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnect
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询