How to insert,Update,Delete data in a Database using DataSet and show data in a GridView

If you are new to ADO.NET then I will suggest you to see my previous article
How to add DataSet and Add Database table to a DataSet


We will start from our previous article where we create a dataset and put two tables on that dataset.
1.(To find your DataSet)Solution Explorer->Click on App_Code smart tag->You will see your DataSet->Double click on Dataset so that it will show on Design window.

2.Right Click on your desired table(here Login table)->Add->Click Query->Next(Make sure Use Sql Statements is selected)->Select Insert->Next->(It's optional you can click Query Builder to see your query is working properly->Click Execute Query->Insert your value->Ok->You will see a message one row affected->Ok->Ok)->Next->Next->Finish
Insert data to a Database using DataSet












3.Add a new windows form->Add two label,two textbox and a Button->Also add a Gridview->
Your Design window should look like this
Insert Data Into database with database using c#
4.Click smart tag of your GridView->Select New DataSource
Asp.net GridView









Select Object->Ok->Select your Table Adapter->Finish->Checked the CheckBox Enable Sorting,Editing,Deleting,selecting(as your requirement)

5.Double click on the Button(Insert button)->And write this code


6.Click F5 to run your project

Insert Data into DataBase and Shown in a GridView


No comments:

Post a Comment