Time column in mysql - DateTime datatype in .net?

Time column in mysql - DateTime datatype in .net?

Postby shutterstock » Wed 29 Mar 2006 19:11

How come we can't use GetDateTime for a time column? it has to be a string?

is there any other Get datatype we can use?

if there a reference chart in the docs that maps C# datatypes to mysql datatypes?

thanks!
Jon
shutterstock
 
Posts: 27
Joined: Sat 28 May 2005 20:37

Postby Alexey » Thu 30 Mar 2006 08:37

If you want to find out which types returns your resultset use MySqlDataAdapter in design time:
1. Place one on the form, right-click it and choose Configure Data Adapter... item from context menu.
2. Type your select query and press Preview... button.
3. In "Preview Data:" window press Schema Tables button and take a look on DataType column.

If you want to have a string representation of data use GetString method of the MySqlDataReader.

If GetDateTime method doesn't work properly please specify the problem.
Hopefully, the following example will be helpful:

Code: Select all
      сonnection.Open();
      MySqlDataReader reader = сommand.ExecuteReader();
      StringBuilder myStr = new StringBuilder("");
      while (reader.Read())
        myStr.Append(reader.GetDateTime(4));

Where 4 - is the number of the column that is of DateTime type in the appropriate table.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for MySQL