467,077 Members | 1,033 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Display Search Results in DataGrid

hyy all
I m new to C#, so please ignore if I use wrong terms.
I m working on a single form application in VS2010, with sql database. I have successfully inserted the data in to database table.

but search is the problem, when ever i try to perform the search the datagridview control displays all the data present in the database.

this is what I m doing...
Expand|Select|Wrap|Line Numbers
  1. private void btnSearchName_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 sqlcon.Open();
  6.                 sqlcmd = new SqlCommand("select * from tblContacts where NAME = ('"+ txtSearchName.Text +"')") ;
  7.                 sqlcon.Close();
  8.  
but this query returns all the data present in the database, please see attachment.

thanks
Attached Images
File Type: jpg Untitled.jpg (31.7 KB, 64 views)
Aug 27 '14 #1
  • viewed: 982
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Alexandre Plennevaux | last post: by
3 posts views Thread by Jimmy | last post: by
2 posts views Thread by Steven Smith | last post: by
reply views Thread by =?Utf-8?B?Qm9ubmll?= | last post: by
4 posts views Thread by PI | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.