欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

<%

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 使用NextRecordset通过一个Connection输出多个select查询
分享到: 更多 (0)

相关推荐

  • 暂无文章