How to Load Data in the DataGridView in C# and SQL Server

0
1156

How to Load Data in the DataGridView in C# and SQL Server

In this tutorial, I will teach you how to Load Data data in Datagridview using C# and SQL server 2005. This method will help you retrieve data in the database to load those data in the DataGridview. You can also control whatever data you want to display to the DataGridView.

LoadDataSQLDTGfig.3

 

Let’s Begin How to Populate Datagridview using C# and SQL server:

 

Create a database and name it “persondb”.

After that, do the following query for creating a table in the database that you have created.

Open Microsoft Visual Studio 2008 and create a new Windows Form Application for C#. Then do the following design of a Form as shown below.

LoadDataSQLDTGfig.1

Go to the Solution Explorer, double click the “View Code”  to display the code editor.

LoadDataSQLDTGfig.2

In the code editor, declare all the classes and variables that are needed.

Note: Put using System.Data.SqlClient; above the namespace to access sql server library.

After declaring the classes and variables, go back to the design view double click the form and establish a connection between SQL server and C#.net in the first load of the Form.

Create a method for retrieving data in the database to be displayed in the datagridview.

After declaring the creating a method, go back to the design view double click the”Load” button.

 

Output:

LoadDataSQLDTGfig.3

Before we proceed watch first the video how Load MySQL Data using VB.Net in Datagridveiw

For all students who need a programmer for your thesis system or anyone who needs a sourcecode in any programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – TNT

 

You can download the full source here Sourcecode

If you have any questions or suggestions about this tutorial on to Load Data data in Datagridview using C# and SQL server, please feel free to leave a comment below.

NO COMMENTS

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.