DateTime in SQL Server 2005
hello!
i can't save to database, CALENDERED_DATE datatype is DateTime in SQL Server
i keep on seeing this error: "Incorrect Syntax near '#'."
comm.CommandText = "SELECT * FROM tblData WHERE RACK_NO = '"+ cboRackNo.Text +"' AND CALENDERED_DATE = #"+ Convert.ToDateTime(dtpCalenderedDate.Text).ToShortDateString() +"# AND SHIFT = '"+ cboShift.Text +"' AND ROLL_NO = "+ txtRollNo.Text +" AND POSITION = '"+ cboPosition.Text +"'";
even i remove the "Convert function"
this is the debug result:
? comm.CommandText
"SELECT * FROM tblData WHERE RACK_NO = 'PW947' AND CALENDERED_DATE = #6/27/2007# AND SHIFT = 'Swing' AND ROLL_NO = 1 AND POSITION = 'T'"
in reading the result i dont see any error.
any idea how to solve?
tnx in advance.
Re: DateTime in SQL Server 2005
In case of #Date# use 'Date' in SQL Server
Rajib
Re: DateTime in SQL Server 2005
thank you for the info.
could you explain why it don't need #(pound sign) but in msaccess needs?
i know they are different but they are both microsoft
Re: DateTime in SQL Server 2005
Maybe # isn't a standard complaint to ANSI SQL definition? And microsoft is devoting MSSQL to comply with the standards but not MS Access? I could be wrong here.