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
Time column in mysql - DateTime datatype in .net?
-
- Posts: 27
- Joined: Sat 28 May 2005 20: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:
Where 4 - is the number of the column that is of DateTime type in the appropriate table.
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));