Display Search Results in DataGrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fadee2
    New Member
    • Aug 2014
    • 1

    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...
    Code:
    private void btnSearchName_Click(object sender, EventArgs e)
            {
                try
                {
                    sqlcon.Open();
                    sqlcmd = new SqlCommand("select * from tblContacts where NAME = ('"+ txtSearchName.Text +"')") ;
                    sqlcon.Close();
    but this query returns all the data present in the database, please see attachment.

    thanks
    Attached Files
Working...