zoukankan
html css js c++ java
ASP和ASP.net中多结果集的返回
<
%
'
'
Made by Goodspeed
'
'
Option
Explicit
Response.Buffer
=
True
'
sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
Const
SqlUsername
=
"
sa"
Const
SqlPassword
=
"
qwe"
Const
SqlDatabaseName
=
"
NorthWind"
Const
SqlLocalName
=
"
127.0.0.1"
Dim
ConnStr
ConnStr
=
"
Provider = Sqloledb; User ID =
"
&
SqlUsername
&
"
; Password =
"
&
SqlPassword
&
"
; Initial Catalog =
"
&
SqlDatabaseName
&
"
; Data Source =
"
&
SqlLocalName
&
"
;"
'
打开数据库
Dim
Conn
Set
Conn
=
server.
createobject
(
"
adodb.connection
"
)
Conn.Open ConnStr
%
>
<
html
>
<
head
>
<
title
>
ASP Test
</
title
>
<
meta http
-
equiv
=
"
Content-Type
"
content
=
"
text/html; charset=gb2312
"
>
</
head
>
<
body
>
<
table
>
<
%
Dim
rs, rs1,strSQL, Field, strResponse,cmd,rs2
Set
rs
=
Server.
CreateObject
(
"
ADODB.Recordset
"
)
'
建立记录集对象
Set
cmd
=
Server.
CreateObject
(
"
ADODB.Command
"
)
'
建立命令对象
set
cmd.ActiveConnection
=
Conn
cmd.CommandText
=
"
aaa"
cmd.CommandType
=
4
'
命令类别为4,表示为存储过程
set
rs
=
cmd.
execute
Do
Until rs
is
nothing
'
输出表头
strResponse
=
"
<tr>"
For
Each
Field In rs.Fields
strResponse
=
strResponse
&
"
<td>
"
&
Field.Name
&
"
</td>"
Next
strResponse
=
strResponse
&
"
</tr>"
'
输出表体
Do
Until rs.EOF
strResponse
=
strResponse
&
"
<tr>"
For
Each
Field In rs.Fields
strResponse
=
strResponse
&
"
<td>
"
&
rs(Field.Name)
&
"
</td>"
Next
strResponse
=
strResponse
&
"
</tr>"
rs.MoveNext
Loop
Set
rs
=
rs.
NextRecordset
()
Loop
Set
rs
=
nothing
Response.Write (strResponse)
%
>
</
table
>
</
body
>
</
html
>
<
%
Conn.Close()
Set
Conn
=
nothing
%
>
<
script runat
=
"
server
"
>
void
Page_Load(
object
sender, EventArgs e)
{
System.Data.DataSet ds
=
SqlHelper.ExecuteDataSet(
"
aaa
"
);
GridView1.DataSource
=
ds.Tables[
1
];
GridView1.DataBind();
}
</
script
>
查看全文
相关阅读:
[转]几个开源的.net界面控件
电脑上设置对眼睛友好的绿豆沙色
[转] C# 绘制报表,使用Graphics.DrawString 方法
Excel 绘制图表,如何显示横轴的数据范围
[转] C#中绘制矢量图形
Chapter 3 Protecting the Data(3):创建和使用数据库角色
续x奇数倍(n+2*x)暴力算法是冠军的算法结合数量
新秀学习SSH(十四)——Spring集装箱AOP其原理——动态代理
中国是大数据的人工智能的发源地
采用shell脚本统计代码的行数
原文地址:https://www.cnblogs.com/goodspeed/p/42632.html
最新文章
iOS开发宝典:String用法大全
【Java线程】锁机制:synchronized、Lock、Condition
Java:使用synchronized和Lock对象获取对象锁
java enum(枚举)使用详解 + 总结
Java 理论与实践: 处理 InterruptedException
多线程wait()和sleep()以及InterruptedException异常
android蓝牙的调试(博通蓝牙工作 and 低功耗模式)
Android动态设定GridView的高度,固定column,实现高度自适应
android Listview,gridview局部刷新,部分刷新
Android中Bitmap,byte[],Drawable相互转化
热门文章
socket示例代码演示程序(螺纹)
Qt Mac 在软件 icns图标制作
ACdream 1427 Nice Sequence
CCBValue
AndroidManifest:VersionCode和VersionName
推荐他们认为有用Sublime Text3小工具
JavaScript语言基础知识7
提高duilib的richedit控制的一些特征
php 简单的存在 (方法之间的神奇作用:容错)
Mac周边环境 goBASIC语言HelloWorld
Copyright © 2011-2022 走看看