I have an MFC application using OBDC to access the MS Access Database.
I am trying to insert a new record into the table, but I get a First-chance exception at 0x7705C44D in WinPASS.exe: Microsoft C++ exception: int at memory location 0x0039D470.
Here is the code
CDatabase db;
LPCTSTR lpszConnect = _T("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=C:\\Users\\New folder\\AccessDB.accdb;");
BOOL result = db.OpenEx(lpszConnect, CDatabase::noOdbcDialog);
CString test;
if (!result)
{
AfxMessageBox("Could not find AccessDBfile");
}
CString sql;
sql.Format("INSERT INTO UserSelection( GroupName ) VALUES ( 'Something' )");
try
{
db.ExecuteSQL(sql);
}
catch (CDBException* pe)
{
pe->ReportError();
pe->Delete();
AfxMessageBox(pe->m_strError);
}
This code is actually on a loop, the first time running it will create the exception error on the second run AND insert the information in the table. So it basically works, this is an odd error. Does anyone have any idea of what might be wrong?
EDIT: Forgot to add, it doesn't crash just have that exception at ExecuteSQL
. Also, CDBException
does not catch that error.
Thanks.