Gaurav Singh

Gaurav Singh

  • NA
  • 0
  • 25.3k

Error Ado.Net/ Sql/C# need help please

Apr 29 2015 5:58 PM
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '='.
Line 25: da = new SqlDataAdapter(strQuery, con);
Line 26: DataSet ds = new DataSet(); 
Line 27: da.Fill(ds,"Students"); 
Line 28:  
Line 29:ViewState["Sql_Query"] = strQuery;
i didnt understand why i am getting this error and how do i solve it?
my Codes:
 
string strQuery = "Select * from tblStudent where ID = " + txtID.Text;
da = new SqlDataAdapter(strQuery, con);
DataSet ds = new DataSet();
da.Fill(ds,"Students");

Answers (5)