What is wrong ?
-
I am trying to do a search. When I type a character inside the textbox it should take all the feild value which starts with that character. Below code it is not showing any error, but not binding to the datagrid. string s = "%S" + TextBox5.Text + "%"; string d = "SELECT field1, field2,... FROM OUTSTANDING WHERE field1 LIKE '"+ s +"'"; try{ OdbcCommand CMD = new OdbcCommand(d, c); DataSet DT = new DataSet(); c.Open(); OdbcDataAdapter a = new OdbcDataAdapter(CMD); CMD.ExecuteNonQuery(); a.Fill(DT, Tablename); GridView1.DataSource = DT; GridView1.DataBind(); }
-
I am trying to do a search. When I type a character inside the textbox it should take all the feild value which starts with that character. Below code it is not showing any error, but not binding to the datagrid. string s = "%S" + TextBox5.Text + "%"; string d = "SELECT field1, field2,... FROM OUTSTANDING WHERE field1 LIKE '"+ s +"'"; try{ OdbcCommand CMD = new OdbcCommand(d, c); DataSet DT = new DataSet(); c.Open(); OdbcDataAdapter a = new OdbcDataAdapter(CMD); CMD.ExecuteNonQuery(); a.Fill(DT, Tablename); GridView1.DataSource = DT; GridView1.DataBind(); }
Your code is not secure, but I assume from the variable names that this isn't code that will be used in the real world anyhow ?
A kamath wrote:
string s = "%S" + TextBox5.Text + "%";
If you type in e, you will search for anything that starts with Se. Turn %S into % and it will work the way you described it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Your code is not secure, but I assume from the variable names that this isn't code that will be used in the real world anyhow ?
A kamath wrote:
string s = "%S" + TextBox5.Text + "%";
If you type in e, you will search for anything that starts with Se. Turn %S into % and it will work the way you described it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )