Non-linked access to the database-the queried dataset is stored with a dataset.

Source: Internet
Author: User

 Private voidButton_click_1 (Objectsender, RoutedEventArgs e) {            //accessing the database in a non-linked way,//1 Creating a Connection object (connection string)            using(SqlConnection conn =NewSqlConnection (sqlhelper.connectionstring)) {                //2. Create a data adapter object                using(SqlDataAdapter SDA =NewSqlDataAdapter ("SELECT * from Student", conn)) {                     //3. Open the database connection (this step can actually be omitted)Conn.                    Open (); DataSet DS=NewDataSet (); //4. Send commandSDA.                    Fill (DS); //5. Close the connection//Note: Because the using code block is used here, the close step of the connection can be omittedDataRowCollection drcollection = ds. tables[0].                    Rows;  for(inti =0; i < Drcollection.count; i++) {DataRow Dr=Drcollection[i]; MessageBox.Show (dr["S_name"].                    ToString ()); }                                }                        }                   }

Note: The dataset is in memory, and we query how much of your data you have and how much memory you have.

Non-linked access to the database-the queried dataset is stored with a dataset.

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.