Menu

#12 [OLE DB]timestamp data type problem

open
nobody
None
5
2011-08-25
2011-08-25
Jira Trac
No

Brief:
# A runtime exception is throwed when call OleDbDataReader.GetDateTime() to get a cubrid timestamp data

Exception content:
# HEAP CORRUPTION DETECTED: after Normal block (#198) at 0x05056378.
# CRT detected that the application wrote to memory after end of heap buffer.

Test Step:
# insert into datatable a timestamp value
# call OleDbDataReader.GetDataTime(int colIndex) method to get the value

Code reference:
{code}
[Test, Description(test datareader GetDateTime(db_type:timestamp, .net_type:datetime))]
public void DataReader_GetDateTime_TimeStamp()
{
string strTable = t_type_datetime;
string strCreateTable = string.Format(Create table {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,f_timestamp timestamp), strTable);
string strDropTable = string.Format(Drop table {0}, strTable);
DateTime exp = System.DateTime.Now;
string sDateTime = exp.ToString(yyyy-MM-dd HH:mm:ss);
OleDbUtil oUtil = new OleDbUtil(strConn);
OleDbCommand cmdCubrid = oUtil.CreateCommand(strDropTable);

try
{
cmdCubrid.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
cmdCubrid.CommandText = strCreateTable;
cmdCubrid.ExecuteNonQuery();

string strInsert = string.Format(insert into {0} value(NULL,'{1}'), strTable, sDateTime);
string strSelect = string.Format(select * from {0} order by id desc, strTable);
SqlUtil.ExecuteNonQuery(oUtil.ConnCubrid, strInsert);
OleDbDataReader reader = oUtil.CreateReader(strSelect);
Assert.AreEqual(exp, reader.GetDateTime(1));
//Assert.AreEqual(exp, reader.GetTimeSpan(1));
reader.Close();
oUtil.CmdCubrid.Dispose();
oUtil.ConnCubrid.Close();
}
{code}

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.