Parameterized query & datetime2

  • Thread starter Thread starter Roy
  • Start date Start date
R

Roy

I am using a query for a SqlDataAdaptor to populate the DataSet a table. I
use SqlCommandBuilder to create Insert/Update/Delete query. Can parameterized
query be used in such a case such as WHERE MyColumn = @MyParameter?

For a datatime2 column, what is the format for query?
string.Format("WHERE MyDatetimeColumn = '{0}'",
myDatetime.ToString("yyyy-MM-ddTHH:mm:ss.fff")) only gives to the
millisecond. How to be as accurate as ticks?
 
Roy,

Be aware that a datetime column in SQL server before 2005 is very much less
precise then in Net.

By instance is the startdate the date that in the Britisch Empire as last
country in the western atmosfeer the Gregorian calendar was using instead as
the Julian one. (And therefore as well for the British colonies in America,
in the Spanish and French colonies that was about 200 years earlier).

Cor
 
I am talking about datetime2 in SQL Server 2008. It is supposed to be in
ticks. How do I convert the DateTime into query string which is in ticks?
 
Roy,

Why should that affect the AdoNet parameter, be aware that a DateTime
structure in Net is as well a long in ticks starting at 0001 and ending at
9999 (this is not actual true), however for those living then it is probably
no problem.

Therefore it should in my idea even match more.

Cor
 
Back
Top