Bug #6694 MySqlCommand reader not returning TIMESTAMP columns
Submitted: 18 Nov 2004 6:28 Modified: 10 Dec 2004 19:37
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.2 OS:Windows (Windows XP)
Assigned to: Reggie Burnett CPU Architecture:Any

[18 Nov 2004 6:28] [ name withheld ]
Description:
I have the following table created:

mysql> desc apptdb;
+------------+-------------+------+-----+-------------------+----------------+
| Field      | Type        | Null | Key | Default           | Extra          |
+------------+-------------+------+-----+-------------------+----------------+
| apptid     | int(11)     |      | PRI | NULL              | auto_increment |
| createtime | timestamp   | YES  |     | CURRENT_TIMESTAMP |                |
| email      | varchar(50) |      |     |                   |                |
| appt       | date        |      |     | 0000-00-00        |                |
+------------+-------------+------+-----+-------------------+----------------+
4 rows in set (0.00 sec)

When I perform the following query from the command line, I get this result:

mysql> SELECT apptid, createtime, email, YEAR(appt) as year, MONTH(appt) as month FROM apptdb ORDER BY appt;
+--------+---------------------+---------------+------+-------+
| apptid | createtime          | email         | year | month |
+--------+---------------------+---------------+------+-------+
|      1 | 2004-11-03 13:44:23 | test@test.com | 2005 |     1 |
+--------+---------------------+---------------+------+-------+
1 row in set (0.00 sec)

However, using the MySql connector for .Net, when I run the same query on an asp.net page and bind the results to a datagrid, I only get the following listed:

apptid          email                     year          month 
1                test@test.com        2005          1 

For some reason, the timestamp is not being returned properly.

How to repeat:
Create a table with a timestamp column. Perform a query returning a row from the table. Note that the timestamp column is not returned.

Suggested fix:
Return the timestamp column as expected.
[18 Nov 2004 6:31] [ name withheld ]
Just in case you need this as well, here is the asp.net code behind class:

		protected DataGrid table;

		private void Page_Load(object sender, System.EventArgs e)
		{
			string query = "SELECT apptid, createtime, email, YEAR(appt) as year, MONTH(appt) as month FROM " +
				Constants.DB_TABLE_APPOINTMENTS + " ORDER BY appt";
			using(MySqlConnection con = new MySqlConnection(Constants.DB_CONNECT_STRING))
			using(MySqlCommand cmd = new MySqlCommand(query, con))
			{
				con.Open();
				table.DataSource = cmd.ExecuteReader(
					CommandBehavior.CloseConnection | 
					CommandBehavior.SingleResult);
				table.DataBind();
			}
		}

And here is the .aspx page:

<%@ Page language="c#" Codebehind="appt_reminder.aspx.cs" AutoEventWireup="false" Inherits="hpvtest.admin.appt_reminder" ClientTarget="uplevel" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html>
  <head>
    <title>Appointment Reminder Table</title>
  </head>
  <body>
  <asp:DataGrid ID="table" HorizontalAlign="Center" CellPadding="3" Runat="server"/>
  </body>
</html>
[10 Dec 2004 19:37] Reggie Burnett
Thank you for taking the time to report a problem.  Unfortunately
you are not using a current version of the product your reported a
problem with -- the problem might already be fixed. Please download
a new version from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions,
please change the version on this bug report to the version you
tested and change the status back to "Open".  Again, thank you for
your continued support of MySQL.

Additional info:

By marking this not a bug, I am not saying it wasn't a bug.  I wasn't able to reproduce this but I have made some changes to how datetimes are handled and I believe this might have been corrected in the progress.  Please let me know if this is still a problem with 1.0.3