One of the methods of SqlDataAdapter fill (DataSet DataSet, String DataTable) explains

Source: Internet
Author: User

One of the methods of SqlDataAdapter. Fill (DataSet DataSet, String DataTable) explains:
Populates a DataSet with a DataTable name.
Myda. Fill (ds, strtable);
Strtable is not a variable, it is a virtual table
When you get a table of a database from a SQL statement and populate it with a dataset, the dataset is a virtual table, like a view, now the strtable represents the collection of data you need, the virtual table ~ ~ So strtable must hit ""
Myda. Fill (ds, "strtable");
Can not need strtable, direct Myda. Fill (DS); The Fill (DataSet DataSet) method is used, and the return value is the number of rows that were successfully added or updated.
Two, the tables parameter question about the dataset
Da. Fill (DS)--No table name specified here
Gridview.datasource = ds. Tables (0)--so here with Tables (0)

C # if
Da. Fill (ds, "Usertablename")
Gridview.datasource = ds. tables["Usertablename"]--here you can use the name
Because a dataset can put down a lot of tables, generally read the database when the data is populated by default in the first table of the dataset, its index is 0, so here with tables (0), especially the first DataTable in the DataSet.

Index value, starting from 0
For example, if there are more than one table set in the dataset, it can be accessed by index;
St_dd. Tables[0]: Take the first sheet in the ST_DD
St_dd. Tables[0]. Rows[0]: Take the first row of the first table in the ST_DD
The problem with today is that the values taken from the database are placed in the dataset, so how do you tell if there are any tables in the dataset, and if so, are there any data in this table?
This should be judged as follows:
if (DataSet. tables.count==0)//indicates that there are no tables in the dataset
if (DataSet. Tables.count==1&&dataset. Tables[0]. rows.count==0)
Indicates that there is a table in the dataset, but there is no data in this table
DataView represents a custom view of the bindable data for sorting, filtering, searching, editing, and navigating a DataTable.
A DataTable represents a table of data in memory.

One of the methods of SqlDataAdapter fill (DataSet DataSet, String DataTable) explains

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.