G
Guest
I am using the same code to query different databases, one SQL 2005 and the
other SQL 2000. The query contains a date paremeter @Date...
Me.SqlSelectCommand1.Parameters.AddRange(New
System.Data.SqlClient.SqlParameter() {New
System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime,
8, "Date")})
The code was written using VS2003 (.Net 1.1) and is now executing on .Net 2.0.
SQL Profiler displays the generated query for SQL 2000 as...
exec sp_executesql N'SELECT FunctionID, Name, Date, Description FROM
vwTicketedFunctions WHERE (Date >= @Date) AND (OnSaleDate <= @Date) ORDER BY
StartTime', N'@Date datetime', @Date = 'Oct 26 2007 12:00:00:000AM'
and the generated query for SQL 2005 as ...
exec sp_executesql N'SELECT FunctionID, Name, Date, Description FROM
vwTicketedFunctions WHERE (Date >= @Date) AND
(OnSaleDate <= @Date) ORDER BY StartTime',N'@Date
datetime',@Date=''2007-10-26 00:00:00:000''
Note that the date paremeter formats are different. My problem is that the
SQL 2000 query parses Ok but the SQL 2005 generates the error: Line 2:
Incorrect syntax near '2007'.
Note also that regional setting is English(Australia).
other SQL 2000. The query contains a date paremeter @Date...
Me.SqlSelectCommand1.Parameters.AddRange(New
System.Data.SqlClient.SqlParameter() {New
System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime,
8, "Date")})
The code was written using VS2003 (.Net 1.1) and is now executing on .Net 2.0.
SQL Profiler displays the generated query for SQL 2000 as...
exec sp_executesql N'SELECT FunctionID, Name, Date, Description FROM
vwTicketedFunctions WHERE (Date >= @Date) AND (OnSaleDate <= @Date) ORDER BY
StartTime', N'@Date datetime', @Date = 'Oct 26 2007 12:00:00:000AM'
and the generated query for SQL 2005 as ...
exec sp_executesql N'SELECT FunctionID, Name, Date, Description FROM
vwTicketedFunctions WHERE (Date >= @Date) AND
(OnSaleDate <= @Date) ORDER BY StartTime',N'@Date
datetime',@Date=''2007-10-26 00:00:00:000''
Note that the date paremeter formats are different. My problem is that the
SQL 2000 query parses Ok but the SQL 2005 generates the error: Line 2:
Incorrect syntax near '2007'.
Note also that regional setting is English(Australia).