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.