* Brief:
** if use Reader.GetBoolean to get a bit data, it will throw an exception
** Excetion: System.InvalidCastException : 由于符号不匹配或数据溢出以外的其他原因,未能转换数据值。例如,数据在数据存储区中已损坏,但该行仍可以检索。
* Test Code
{noformat}
public void DataReader_GetBoolean_Bit(){
string strTable = t_type_bit;
string strConnection=Provider=CUBRIDProvider;Data Source=testdb;Location=127.0.0.1;User ID=dba;Password=xxx;Port= 33000
string strCreateTable = string.Format(Create table {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,f_bit bit), strTable);
string strDropTable = string.Format(Drop table {0}, strTable);
string strInsert = string.Format(insert into {0} value(NULL,{1}), strTable, B'0');
string strSelect = string.Format(select * from {0} order by id desc, strTable);
OleDbConnection connCubrid = new OleDbConnection(strConnection);
ReaderDataPrepare(connCubrid, new string[] { strDropTable, strCreateTable, strInsert });
OleDbCommand cmdCubrid = new OleDbCommand(strSelect, connCubrid);
OleDbDataReader reader = cmdCubrid.ExecuteReader();
reader.Read();
reader.Read();
Assert.AreEqual(0, reader.GetBoolean(1));
}
private void ReaderDataPrepare(OleDbConnection conn, params string[] cmdText)
{
for (int i = 0; i cmdText.Length; i++)
{
try
{
ExecuteNonQuery(conn, cmdText[i]);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
public static int ExecuteNonQuery(OleDbConnection conn,string strSql)
{
OleDbCommand cmd = new OleDbCommand(strSql, conn);
try
{
return cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
cmd.Dispose();
Console.WriteLine(Exception of ExecuteNonQuery: + ex.Message);
}
return -1;
}
{noformat}