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
>
查看全文
相关阅读:
VMware下桥接设置
oracle 当行函数
oracle基于scott用户的经典sql 面试题(一)
java 公平打乱数组顺序 重新排列
学习.NET3中
坚持
分组小计合计报表的SQL
使用ObjectDataSource注意DeleteMethod、UpdateMethod、Insert等方法中参数的命名约定
SQL语句like子句中的转义符
Oracle数据迁移:从存储了中文的但字符集为WE8ISO8859P1数据库导入数据到字符集为ZHS16GBK的数据库
原文地址:https://www.cnblogs.com/goodspeed/p/42632.html
最新文章
Liferay是什么
Liferay开发模式
js 堆排序过程
asp.net获取客户端信息
word 2010技巧
VS2010帮助文档换位置
DataTable的排序、检索、合并
解决"应用程序配置不正确,程序无法启动"
VSS (Visual Source Safe 2005) 用法详解
C#移位运算(左移和右移)
热门文章
SQL Server 2000 + 2005 + 2008 + 2008R2,完全可以共存,注意区别连接字符串写法
Win7系统中必需记住的14个常用快捷键
利用webBrowser实现万能打印
SQL Server如何保证可空字段中非空值唯一
is not in the sudoers file 的解决办法
Linux系统安装时分区的选择(推荐)
执行mount命令时找不到介质或者mount:no medium found的解决办法
[转]虚拟机VMware3种网络模式(桥接、nat、Hostonly)的工作原理
linux更新系统时,提示var空间不足的解决办法
Linux下硬盘的表示以及相关知识
Copyright © 2011-2022 走看看