Home > DeveloperSection > Forums > Search using textbox value and wildcard character
Tanuj Kumar

Total Post:134

Posted on    August-29-2014 1:12 AM


 1 Reply(s)
 1180  View(s)
Rate this:

I want to search the empid of a name that with the characters entered in my textbox. using wildcard characters. I wrote the statement

da = new SqlDataAdapter(

 "Select empID from emp where FirstName like ' "+textbox1.text+" ' % "

   , connstring);


Is this statement correct?

Sumit Kesarwani

Total Post:378

Posted on    September-01-2014 12:18 AM

string sql = "SELECT empID " +

              "FROM emp " +

              "WHERE FirstName like @FirstName";

using(var con = new SqlConnection(connstring))

using (SqlCommand command = new SqlCommand(sql, con))


    command.Parameters.AddWithValue("@FirstName",  textbox1.text + "%");

    using(var da = new SqlDataAdapter(command))





Don't want to miss updates? Please click the below button!

Follow MindStick