Problem with profiling date time

Hello,

I have a weird problem with profiling datetime using .NET 2.0 code and Sql Server 2005

If I execute the following C# code:

SqlCommand cmd = new SqlCommand("select @TestDate");
cmd.Parameters.AddWithValue("@TestDate", DateTime.Now);
cmd.Connection = conn;
DateTime dt = (DateTime) cmd.ExecuteScalar();

The resulting trace log item is as follow

exec sp_executesql N'select @TestDate',N'@TestDate
datetime',@TestDate=''2006-04-02 18:44:22:687''

That statement will fail when analyzed with DTA since there is a syntax error in the command
e.g.two single quoteat the end and start of the date.

I don't have this problem when executing the same code on Sql Server 2000.

How can I solve this problem?

[979 byte] By [MartinMasse] at [2007-12-19]

SQL Server

Site Classified