Database Reference
In-Depth Information
da.SelectCommand = new SqlCommand(sql, conn);
// Create and Fill Dataset
DataSet ds = new DataSet();
da.Fill(ds, "Person.Contact");
// Get Data Table reference
DataTable dt = ds.Tables["Person.Contact"];
// Create Data View
DataView dv = new DataView(dt,
"MiddleName = 'J.'",
"MiddleName",
DataViewRowState.CurrentRows);
// Display data from data view
gvContact.DataSource = dv;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
finally
{
//Connection close
conn.Close();
}
}
6. To set the FilterSort form as the start-up form, modify the Program.cs
statement.
Application.Run(new FilterSort());
to appear as:
Application.Run(new DataView());
Build the project, and run it by pressing Ctrl+F5. You should see the results in
Figure 15-8.
 
Search WWH ::




Custom Search