Intimate contact asp.net (9)

Source: Internet
Author: User
We continue to the previous content, hehe, this time is mainly about the powerful function of dataset:. The last time we blew up.
Bubbles (The meaning of the words do not count, Hunan people can understand it:), this time must not break the promise:)
Storing multiple data tables in a dataset
Many of us in the ASP are accustomed to using the Recordset object to manipulate the database, but the recordset has a missing
The point is that a recordset can only store one datasheet, and when we need to manipulate multiple tables, we have to work on multiple re
Back and forth in the Cordset, although these are not used after the habit, but for a novice, this is
A very troublesome thing to do. Just those variable names can muddy you, now well, in the ASP.net, only need
A dataset can handle everything. greatly facilitates our program. We still look the same.
Preface, and then to explain carefully.
<% @ Page language= "C #"%>
<% @ Import namespace= "System.Data"%>
<% @ Import namespace= "System.Data.ADO"%>
<script language= "C #" runat= "Server" >
public void Page_Load (Object Src,eventargs E)
{
Join statement
String myConnString = "Driver={microsoft Access Driver (*.mdb)};
Dbq=c:/test/test.mdb; ";
String strComm1 = "SELECT * from UserList";
String strComm2 = "SELECT * from Booklist";
Open a Join
ADOConnection myconnection = new ADOConnection (myConnString);
Open two DataSetCommand
Adodatasetcommand MyComm1 = new Adodatasetcommand (strcomm1,myconnection);
Adodatasetcommand MyComm2 = new Adodatasetcommand (strcomm2,myconnection);
DataSet myDataSet = new DataSet ();
Save a userlist,booklist table in a dataset
Mycomm1.filldataset (myDataSet, "userlist");
Mycomm2.filldataset (myDataSet, "Booklist");
DataGrid1.DataSource = mydataset.tables["UserList"]. DefaultView;

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.