Showing posts with label Retrieve Data. Show all posts
Showing posts with label Retrieve Data. Show all posts

DataGridView Filter & Expressions C# 5.0


Often we need to filter a DataGridView in our database programs. The C# datagrid is the best tool for database display & modification. There is an easy shortcut to filtering a DataTable in C# for the DataGridView. This is done by simply applying an expression to the required column. The expression contains the value of the filter to be applied. The filtered DataTable must be then set as the DataSource of the DataGridView.


Insert & Retrieve from Service Based Database

Now, we go a bit deeper in the SQL database in C# as we learn how to Insert as well as Retrieve a record from a Database. Start off by creating a Service Based Database which accompanies the default created form named form1. Click Next until finished. A Dataset should be automatically created. Next double click on the Database1.mdf file in the solution explorer (Ctrl + Alt + L) and carefully select the connection string. Format it in the way as shown below by adding the @ sign and removing a couple of "=" signs in between. The connection string in .Net Framework 4.0 does not need the removal of @ & "=" signs. The String is generated perfectly ready to use. This step only applies to .Net Framework 1.0 & 2.0.