Close access to ASP. Net (9)

Source: Internet
Author: User

Let's continue with the previous content. Oh, this time we mainly talk about the powerful functions of DataSet :). The previous one blew everyone's
Bubble (the meaning of the words is not counted, so Hunan people can understand it). This time, we will not be able to say anything again :)
Store multiple data tables in one DataSet
Many of us are used to using RecordSet objects to operate databases in ASP, but there is a shortage of RecordSet objects.
Point is that A RecordSet can only store one data table. When we need to operate multiple tables, we have
Although there is nothing to do with these operations in cordSet, this is also true for a newbie.
A very troublesome thing. Just those variable names can confuse you. Now, in ASP. Net, you only need
One DataSet can handle everything. This greatly facilitates our program. We are still the same. Let's take a look at Cheng.
For more information.
<% @ 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. mdb ;";
String strComm1 = "select * from UserList ";
String strComm2 = "select * from BookList ";
// Open a connection
ADOConnection MyConnection = new ADOConnection (MyConnString );
// Open two datasetcommands
ADODataSetCommand MyComm1 = new ADODataSetCommand (strComm1, MyConnection );
ADODataSetCommand MyComm2 = new ADODataSetCommand (strComm2, MyConnection );
DataSet MyDataSet = new DataSet ();
// Store the UserList and BookList tables into DataSet
MyComm1.FillDataSet (MyDataSet, "UserList ");
MyComm2.FillDataSet (MyDataSet, "BookList ");
DataGrid1.DataSource = MyDataSet. Tables ["UserList"]. DefaultView;

Related Article

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.