Menu

#469 [ADO.NET] CUBRIDCommand.GetGeneratedKeys() throws an exception saying AutoCommit must be false

open
nobody
None
5
2013-03-22
2013-03-22
Jira Trac
No

Description:
CUBRIDCommand.GetGeneratedKeys() throws an exception saying AutoCommit must be false. Why this method requires the autocommit must be true?

Sample Code:
{noformat}
string sqlTablesCount = select count(*) from db_class;
int tablesCount, newTableCount;

using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();

DBHelper.ExecuteSQL(drop table if exists tkeys, conn);
tablesCount = (int)DBHelper.GetSingleValue(sqlTablesCount, conn);
DBHelper.ExecuteSQL(create table tkeys(id int auto_increment, str string), conn);
newTableCount = (int)DBHelper.GetSingleValue(sqlTablesCount, conn);

//Verify table was created
Assert.IsTrue(newTableCount == tablesCount + 1);

CUBRIDCommand cmd = new CUBRIDCommand(insert into tkeys(str) values('xyz'), conn);
cmd.ExecuteNonQuery();
cmd.CommandText = insert into tkeys(str) values('abcd');
cmd.ExecuteNonQuery();

DbDataReader reader = cmd.GetGeneratedKeys();
}
{noformat}

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.