michaelkrauklis
Programmer
When connected to a data source, I've only done this with MsSQL2k but the same most likely holds true for all ODBC Drivers, usign a CDatabase object you must call CDatabase::Rollback() if your transaction fails. eg:
If you don't call Rollback the SQL transaction that failed is still in a pending state and an assertion in cdbcore.cpp fails when you attempt to make another transaction(the assertion is that there isn't already a transaction pending). This causes your driver to fail in the same manner as if you had called db.ExecuteSQL(SQL) two times in a row without db.CommitTrans() and db.BeginTrans() again. Hope this helps. May save someone the headache I had. MYenigmaSELF:-9
myenigmaself@yahoo.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
Code:
CDatabase db;
db.open("[ODBC Source Name]");
try{
//create SQL statement
CString SQL;
//...
//this is where the exception is thrown
db.ExecuteSQL(SQL);
if(!db.CommitTrans()){
cerr<<"db.CommitTrans() failed"<<endl;
}
}//end try
catch(CDBException *e){
char *error=new char[1000];
e->GetErrorMessage(error,1000);
cerr<<"Error: "<<error<<endl;
cerr<<"Attempt CDatabase::Rollback()"<<endl;
if(db.Rollback()){
cerr<<"Rollback Sucessful\nContinuing..."<<endl;
}
else{
cerr<<"Rollback Fail\nInvaild SQL Driver "
<<"State\nTerminating Program"<<endl;
exit(1);
}
}
myenigmaself@yahoo.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra