Here I will show you how to bind a DataGridView in a windows application with a DataSet and SQLDataSource.
First create a new windows project and add a new form. After that select a DataGridView and drag and drop into the form.
Now choose a new DataSource against the DataGridView.
Select New DataSource and click on the "Add Project Data Source".
Select the Database to proceed.
Now select the DataSet to continue.
Now after that choose the table name which one you want to display. You can choose multiple tables or views.
After that click on the Finish button to complete the process. Now in the bottom of the project you can see there is a DataSet named tblMessage. Open that and remove the columns that you don't want to display.
Now in the View Code section you can see in the Form_Load a new line of code is added. This one is binding the DataGdridView with the DataSet.
Now run the project and you will see in the output your database's table in the DataGridView.
First create a new windows project and add a new form. After that select a DataGridView and drag and drop into the form.
Now choose a new DataSource against the DataGridView.
Select New DataSource and click on the "Add Project Data Source".
Select the Database to proceed.
Now select the DataSet to continue.
Select the ConnectionString and click on the Next button.
After that click on the Finish button to complete the process. Now in the bottom of the project you can see there is a DataSet named tblMessage. Open that and remove the columns that you don't want to display.
Now in the View Code section you can see in the Form_Load a new line of code is added. This one is binding the DataGdridView with the DataSet.
Now run the project and you will see in the output your database's table in the DataGridView.
0 comments:
Post a Comment