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
%>
'
' 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>
void Page_Load(object sender, EventArgs e)
{
System.Data.DataSet ds = SqlHelper.ExecuteDataSet("aaa");
GridView1.DataSource = ds.Tables[1];
GridView1.DataBind();
}
</script>
posted on 2004-09-13 16:49 Goodspeed 阅读(1292) 评论(0) 编辑 收藏 举报