使用NextRecordset通过一个Connection输出多个select查询

2016-01-29 18:34 50 1 收藏

使用NextRecordset通过一个Connection输出多个select查询,使用NextRecordset通过一个Connection输出多个select查询

【 tulaoshi.com - ASP 】

  <%
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
%
 

来源:https://www.tulaoshi.com/n/20160129/1506375.html

延伸阅读
标签: word
将多个Word文档合并成一个   作中我们常常需要将多个Word文档合并成一个,信息量少的时候可以直接复制粘贴。信息量多tulaoshi.com的时候,可以试试这样的方法:选择插入菜单点击对象选项,并在下拉菜单中选择文件中的文字选择要合并到当前文档中的文件,点击插入即可 如何在word中快速生成论文目录   首先给论文的大小标...
  如果你的网页中一个“OnLoad”事件要激活两个以上的JavaScript函数,那怎么办呢?小阳曾查阅了不少资料,结果都不尽如人意,无非是程序员根据情况,把要激活的函数统一放在一个函数里激活。 但作为一个程序员,编写的代码的适用性是很重要的。请看下面一个例子: 运行后你会发现,它只跳出一个“这是JS脚本调用的...
标签: SQLServer
上周﹐被一位網友問到在sql2000中,想選取一張表的第N條記錄怎麼寫?(即如下語句select ID,Name,Title from WebSite order by ID desc 如何改寫以達到目的) 我當時直接就給他回 select ID,Name,Title from WebSite where ID= N 最后這位老兄說如果是ID是連續的話就可以,如果有記錄刪除的話,ID不連續了,就不行了 ,至此才明白他的真正意思...
标签: Web开发
一个可查询所有表的“通用”查询分页类最近突发奇想,希望写出一个可以针对所有表的查询分页类。因为在实际的开发中,恐怕查询并将结果集分页显示是用得最多的代码,而表的结构是多样的,我想尽可能地提高代码的重用率和维护性。 以下是我写的,请各位加以指点,测试,看能否进行更好的改进和更多的支持。 目前还只支持单一的表,不支持联...
标签: SQLServer
  JOIN子句的用法 JOIN是很好用的一个SELECT查询的子句,虽然有了它以后你的查询语句变得非常的长,写错的概率也增大了;可是四分之一柱香以后,你就会彻底的爱上它,因为我决定把它的优点全部展示给你! 为了便于读者接受,我们还是先来建一个数据库吧。 #货物表 create table goods ( id int auto_increment, code var...

经验教程

390

收藏

48
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部