Is there some way to insert a c# datetime in a table
without dealing with culture? The datetime object
probably has som internal representation thats
culture independant and the database probably stores
datetime internally as a long. If i try to insert like
this:

insert into x(somedatefield) values ('datestring')

then i have to format the datetime object in some
culture specific string and make sure the database
uses the same format. Is there some way to insert
a date without dealing with culture settings on
client and db server?

Re: How to insert c# DateTime? by Miha

Miha
Fri Feb 20 08:39:35 CST 2004

Yes, there is.
Use parametrised stataments.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"me" <wtumaxi@forum.dk> wrote in message
news:6fd6d897.0402200518.2542d21b@posting.google.com...
> Is there some way to insert a c# datetime in a table
> without dealing with culture? The datetime object
> probably has som internal representation thats
> culture independant and the database probably stores
> datetime internally as a long. If i try to insert like
> this:
>
> insert into x(somedatefield) values ('datestring')
>
> then i have to format the datetime object in some
> culture specific string and make sure the database
> uses the same format. Is there some way to insert
> a date without dealing with culture settings on
> client and db server?



Re: How to insert c# DateTime? by Jos

Jos
Fri Feb 20 11:52:47 CST 2004

"me" <wtumaxi@forum.dk> wrote in message
news:6fd6d897.0402200518.2542d21b@posting.google.com...
> Is there some way to insert a c# datetime in a table
> without dealing with culture? The datetime object
> probably has som internal representation thats
> culture independant and the database probably stores
> datetime internally as a long. If i try to insert like
> this:
>
> insert into x(somedatefield) values ('datestring')
>
> then i have to format the datetime object in some
> culture specific string and make sure the database
> uses the same format. Is there some way to insert
> a date without dealing with culture settings on
> client and db server?

Apart from Miha's solution with parameters, you should
consider that the format in the SQL statement is NOT culture
specific. Even if the database program shows the data in a
culture specific way, you shouldn't use this format when
using SQL.

In SQL, it is always the American mm-dd-yyyy format.

--

Jos



Re: How to insert c# DateTime? by wtumaxi

wtumaxi
Sun Feb 22 05:33:57 CST 2004

>
> Apart from Miha's solution with parameters, you should
> consider that the format in the SQL statement is NOT culture
> specific. Even if the database program shows the data in a
> culture specific way, you shouldn't use this format when
> using SQL.
>
> In SQL, it is always the American mm-dd-yyyy format.

dosent work here. I have to use yyyy-mm-dd.

i know sql server has a "set" instruction to set the
format explicitly.