New to Telerik UI for WinForms? Download free 30-day trial

How to Bind GridView to a Local SQL Server

Environment

Product Version Product Author
2022.2.622 RadGridView for WinForms Desislava Yordanova

Description

This article offers a step-by-step tutorial how to bind the RadGridView control to the Northwind.Categories table from a local SQL server.

Solution

Consider that we have a local SQL server with the Northwind database:

gridview-databinding-tutorial-sql-server 001

Now, we are going to bind the RadGridView control in the project to the Northwind.Categories table:

gridview-databinding-tutorial-sql-server 002

Let's follow the steps:

1. Select the RadGridView control at design time and open its smart tag. Then, select Choose DataSource >> Add Project Data Source... :

gridview-databinding-tutorial-sql-server 003

2. Follow the wizard:

gridview-databinding-tutorial-sql-server 004

gridview-databinding-tutorial-sql-server 005

gridview-databinding-tutorial-sql-server 006

gridview-databinding-tutorial-sql-server 007

3. Change the Data source to Microsoft SQL Server and press OK:

gridview-databinding-tutorial-sql-server 008

4. Enter your Server name and select the database name, e.g. Northwind:

gridview-databinding-tutorial-sql-server 009

5. Confirm the changes and continue the wizard:

gridview-databinding-tutorial-sql-server 010

6. Select the Northwind.Categories table and click Finish:

gridview-databinding-tutorial-sql-server 011

7. Once the wizard is completed, the respective BindingSource is generated:

gridview-databinding-tutorial-sql-server 012

8. Run the project and the grid will be populated with data:

gridview-databinding-tutorial-sql-server 013

See Also

In this article