How to supply a string for a datetime column in ADO.net
Posted on 2009-04-27
I want to write a select statement in which I supply a string value for a timestamp column (in Sybase Sql Anywhere database)
string dateTimeStr = "2009-04-27 12:34:23";
string selectStr = " Select * from Table where DateTimeColumn =' "+dateTimeStr+" ' ";
When I execute this select statement, the Odbc driver gives an error like :
Can not convert ... to timestamp.
When I use the OdbcParameterCollection of the command and add a c# DateTime type value as the parameter to the select statement, the command executes without error.
Isn't there another way other than using parametres?
It would be really good if I could give a string in the where condition..
Thanks in advance..