|
-
Jun 27th, 2007, 04:25 AM
#1
Thread Starter
Hyperactive Member
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.
*****************
VB6,PHP,VS 2005
-
Jun 27th, 2007, 05:08 AM
#2
Lively Member
Re: DateTime in SQL Server 2005
In case of #Date# use 'Date' in SQL Server
Rajib
Please Rate every reply if it is useful to u
-
Jun 27th, 2007, 07:04 PM
#3
Thread Starter
Hyperactive Member
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
*****************
VB6,PHP,VS 2005
-
Jun 27th, 2007, 10:40 PM
#4
Fanatic Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|