Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

Incorrect syntax near '12'. at DateTime.Today.Date

i have this incorrect syntax
'Incorrect syntax near '12'.'

where the so_order_date is 7/17/2009 12:00:00 AM in SQL Server 2005
string sqlcmddual2 = "USE " + txtProntoDB.Text + "; Select * FROM sales_order WHERE so_bo_suffix = '' AND LEFT(so_order_no, 3)  = 356 AND so_order_date =" + DateTime.Today.Date;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Alpha Au
Alpha Au
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Guy Hengel [angelIII / a3]
note: this syntax is not recommended.
1) using dynamic sql, calling for sql injection
2) not using bind paramters and at the same time no explicit data type conversion (check up CONVERT() function ....)
3) date = date ... I presume the so_order_date might have some time portion stored?
  if so, that sql will never return anything. you must use so_order_date >= {date} and so_order_date < dateadd(day, 1, {date} )