C# : Searching Data in the Datagridview with SQL Server


SearchDTGSQLfig.3In this tutorial, I will teach you how search data in the datagridview using a TextBox in C# and SQL Server 2005. With this, you can search records in the datagridview with ease. This method will help you lessen your work load that you don’t have to scroll down if there’s a lot of data in the datagidview.


Let’s begin:


Create a database and name it “persondb”.

After that, create a table in the database that you have created.

Now , open Microsoft Visual Studio 2008 and create new Windows Form Application for C#. Then do the following design of a Form as follows.



After that, go to the Solution Explorer, double click the “View Code”  to display the code editor.




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

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


After declaring the classes, establish a connection between SQL server and C#.net and retrieve the data in the database to display in the datagridview in the first load of the Form. 


Now, go back to the design views, double click the TextBox and do the following codes for searching data in the datagridview.




For all students who need 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

Facebook Comments


Please enter your comment!
Please enter your name here