Using TableAdapter That Contains DateTime

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
scottb
Posts: 3
Joined: Tue 26 Sep 2006 13:08

Using TableAdapter That Contains DateTime

Post by scottb » Tue 26 Sep 2006 13:50

I am using TableAdapters to connect to a mySQL database that contains a DateTime column. Is there a way to pass a DateTime value from .Net (C#) to a database containing a DateTime column? MSFT and mySQL apparently store dates differently.

Thx
Scott

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 26 Sep 2006 14:08

Please describe in detail what exactly you need or what is the problem.

scottb
Posts: 3
Joined: Tue 26 Sep 2006 13:08

Explanation of what I am doing

Post by scottb » Tue 03 Oct 2006 01:01

I am using a TableAdapter to connect to a mySql database. For background on TableAdapters please see (http://weblogs.asp.net/scottgu/archive/ ... 35498.aspx).

In its most simplified form I have a web form with a single textbox and a submit button. The user enters a date / time in text format as ASP.Net expects it to occur (i.e., MM/DD/YYYY, 1/1/2001). The value from the text box is stored in a DateTime variable.

I would then like to insert this DateTime value (1/1/2001) into a mySql database table with a mySQL date time column. My understanding is that mySQL treats date time variables differently than ASP.Net and expects them to come in as YYYY/MM/DD.

I know I can convert the ASP.Net variable to a string and successfully do an insert if the column is varchar but what I really want to do is insert into an ASP.NET DateTime variable into a mySql column.

Because the tableadapter enforces compile time type checking I do not have the option of passing a mySql reformatted string to the database.

Thank you for your help.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 03 Oct 2006 08:27

The date/time format is adjusted automatically by us when you insert data into a database. So you have nothing to worry about.

Post Reply