Monday, July 7, 2014

Simple DataSet Example with Code

Hello again :)

This time we will see some code for DataSet.
Here we will see how to use Dataset and show the fetched data in GridView.

Code is as below

DataSet dsMainCatagory = new DataSet();
                string query = "select * from tblMainCategoryMaster where Enable=1 and MainCategoryName like'" + txtSearchMainCatagory.Text+ "%" + "'";

                SqlDataAdapter daa = new SqlDataAdapter(query ,global.cn);

                daa.Fill(dsMainCatagory);


                DataView dvw = dsMainCatagory.Tables[0].DefaultView;

                dgvallmaincat.DataSource = dvw;

                dgvallmaincat.Show();


Hope it will save your time in future.

I have post these information regarding DataSet and DataReader because they are mostly asked in Interview.


Enjoy the day with Lots of smile and Happiness.....

No comments:

Post a Comment