Returns of multiple result sets in ASP and Asp.net

Source: Internet
Author: User
< %
'
' Made by Goodspeed
'
'
Option   Explicit  
Response. Buffer =   True
' Sqldatabase connection parameters: Database Name, user password, user name, connection name (local, IP address used in other places)
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 &   " ;"

' Open Database
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 " ) ' Create record set object
Set CMD = Server. Createobject ( " ADODB. Command " ) ' CREATE command object
Set Cmd. activeconnection = Conn
Cmd. commandtext = " AAA"
Cmd. commandtype =   4   ' The command category is 4, indicating the Stored Procedure

Set RS = Cmd. Execute

Do Until rs Is   Nothing

' Output Header
Strresponse =   " <Tr>"
For   Each Field in RS. Fields
Strresponse = Strresponse &   " <TD> "   & Field. Name &   " </TD>"
Next
Strresponse = Strresponse &   " </Tr>"

' Output Table body
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 >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.