Last post Sep 08, 2011 07:25 PM by vmillasp
Sep 06, 2011 08:22 PM|j1234sai|LINK
I have a sql statement
SQL = "select * from Candidate where test_date = " & TextBox2.Text
I am getting error in the line myDataAdapter.Fill(myDataSet)
Conversion failed when converting the varchar value '03/15/11' to data type int
In my sql server test_date column data type is varchar.
Any help will be appreciated.
Sep 06, 2011 08:48 PM|kp8732|LINK
this is in your code behind yes?
May I ask why you are making a call to a text in your SQL statement?
what I would do is setup a paramatized stored procedure, and hand the value of the text box in as a string.
also it appears to be an issue with the type of data the statment is expecting..
I would change the test_date column to a datetime data type if that's indeed what it is..
Sep 06, 2011 08:53 PM|j1234sai|LINK
I am trying to do a sorting on my gridview based on the given date.
Sep 06, 2011 09:16 PM|kp8732|LINK
can you post all of your code?
Sep 08, 2011 07:25 PM|vmillasp|LINK
you need to have double quotes around the date value
SQL = "select * from Candidate where test_date = " & """" & TextBox2.Text & """"
although i do not recomend a simple query like that that could be suspect to attacks on production enviroment.