大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> 使用NextRecordset通过一个Connection输出多个select查询。

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

时间: 2021-07-31 作者:daque

<%dim conndim strconndim rsdim strsql dim strsql2dim strsql3dim strsql4dim strsql5dim strsql6dim strsql7dim 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 parametersstrsql = "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 objectstrsql = 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 variableset conn = server.createobject("adodb.connection")conn.open strconnset rs = server.createobject("adodb.recordset")rs.open strsql, conn 'parses out the individual recordsets and places them'into individual table rowsintcount = 1do until rs is nothingresponse.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 rowsdo while not rs.eofresponse.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 " "elseresponse.write ofield.valueend if response.write "</td>" next rs.movenextloop'uses the nextrecordset methodset rs = rs.nextrecordsetintcount = intcount + 1response.write ""loop%>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.