开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术ASP技巧 → 使用NextRecordset通过一个Connection输出多个select查询
使用NextRecordset通过一个Connection输出多个select查询
日期:2002年6月13日 作者:大洲 人气:     [ ]
<%
dim conn
dim strconn
dim rs
dim strsql
dim strsql2
dim strsql3
dim strsql4
dim strsql5
dim strsql6
dim strsql7
dim strsql8

'strconn = Driver={SQL Server};Description=example;SERVER=222.222.1.2;UID=webexample;PWD=;DATABASE=webexample"


'Format Declare & EXEC statements that will be passed
'to the database with the output parameters
strsql = "DECLARE " & CHR(10) & "@Id_Req " & "INT" & CHR(10)
strsql2 ="exec " & "sp_EmpInfo" & " '" & request("txtFirstName") & "'," & "'" & request("txtLastName") & "', " & "'" & request("txtaddress") & "', " & "'" & request("txtcity") & "', "& "@Id_Req " & "OUTPUT" & chr(10)

'Formats one or more sql statements that will be passed to the
'database In this examples I use six different ways.
strsql3 ="SELECT * FROM AllData WHERE RecordId = @Id_Req" & Chr(10)
strsql4 ="SELECT AllData.fname, AllData.lname FROM Alldata WHERE RecordId = @Id_Req" & Chr(10)
strsql5 ="SELECT AllData.fname FROM AllData WHERE RecordId = @Id_Req" & Chr(10)
strsql6 ="SELECT AllData.lname FROM AllData WHERE RecordId = @Id_Req" & Chr(10)
strsql7 ="SELECT AllData.Address FROM AllData WHERE RecordId = @Id_Req" & Chr(10)
strsql8 ="SELECT AllData.city FROM AllData WHERE RecordId = @Id_Req" & Chr(10)

'Puts together all of the local variables into one variable
'That will be used by the recordset object
strsql = strsql & strsql2 & strsql3 & strsql4 & strsql5 & strsql6 & strsql7 & strsql8

'This is optional this writes out the strsql local variable
'that will be passed to the database
response.write "<b>" & "Sql Statement that is passed to the database" & "</b>" & "<br>"
response.write strsql & "<br>" & "<br>"

'sets a connection & recordset objects and executes the strsql local variable
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs = server.createobject("adodb.recordset")
rs.open strsql, conn

'Parses out the individual recordsets and places them
'into individual table rows
intcount = 1
Do Until rs Is Nothing
response.write "<table border='1' width='25%'>"

response.write "<b> Contents of recordset #" & intCount & "</b><br>"
'Parses out the individual recordsets and places them into table rows
Do While Not rs.EOF
response.write "<TR>"
For Each oField In RS.Fields
response.write "<TH>" & oField.Name & "</TH>"
Next
Response.write "</TR>" & "<TR>"
For Each oField In RS.Fields
response.write "<TD ALIGN=center>"
If IsNull(oField) Then
Response.Write " "
Else
Response.Write oField.Value
End If
response.write "</TD>"
Next
rs.MoveNext
Loop
'Uses the NEXTRECORDSET Method
Set rs = rs.NextRecordset
intCount = intCount + 1
response.write "</table>"
Loop
%>

(出处:开发者俱乐部)

相关文章:
 
·数据库查询中的特殊字符的问题
·在ASP中使用SQL语句之2:用WHERE子句设置查询条件
·在ASP中使用SQL语句之6:存储查询
·组合查询之核心:拼接字符串
·怎么样写一段高效,安全的sql查询代码
·WSH 直接将查询数据结果生成 EXCEL 表
·用 WSH 想ASP 一样 查询数据库
·最简洁的多重查询的解决方案
·关于INDEX SERVER+ASP建立查询引擎的一点心得
·用正则表达式突出显示字符串中查询到的单词的函数
相关软件:
 
·风云在线成绩查询系统 v1.0
·我爱啦(52.La)多功能查询系统
·Alexa排名查询系统超强ASP版 v1.120
·企业员工手机号码查询
·内蒙古工业大学理学院成绩查询系统
·25175 全球邮编、区号查询系统 v1.5
·网站信息查询工具--pr 网站收录查询 Build 0811
·SoGuo火车时刻查询小偷 v2.0
·25175 IP地址归属地查询程序 v1.1
·全国身份证查询系统(带数据库) Build 0719
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077