网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.迁移到 ASP .NET:需考虑的重要问.
.转换文本为超联和Email格式的代码.
.为ASP开发者介绍ColdFusion.
.ASP与Oracle连接时的TNS错误 .
.让你的网站首页自动选择语言.
.ASP原码加密工具介绍.
.不刷新页面筛选数据库中的数据.
.ASP技术在论坛中的运用(三)(吐血.
.ASP技术在论坛中的运用(二)(吐血.
.ASP+SQLServer2000 经验积累.
.如何编写通用的ASP防SQL注入攻击.
.PHP和C通过Socket通信--UDP篇.
.二十八条改善 ASP 性能和外观的技.
.ASP 中 Split 函数的实例.
.改善ASP性能和外观的技巧集锦(上.
.使用组件封装数据库操作(一).
.用ASP建立站内搜索.
.ADO如何使用Update语法呢?(BIG.
.ASP中缓冲的启用及执行速度的影响.
.用TDC建立自己的数据库格式.

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

发表日期:2002-6-12


<%
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中如何创建动态表--调用如下sp_execute 人气:12924
下一篇:一个分页存储过程 人气:13366
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐