Questions tagged [cdatabase]
16 questions
1
vote
0 answers
Why am I getting this exception when shutting down my MFC application that reads a ACCDB database?
I have encountered an issue and can't work out why it is happening.
Context:
Windows 11
Visual Studio 2022
MFC Dialog 64 bit
DEBUG mode
When I run the software in DEBUG mode, and perform a specific action (reading a ACCDB database) and then…

Andrew Truckle
- 17,769
- 16
- 66
- 164
1
vote
1 answer
Correctly catching the CDatabase::Close exception
I thought I would do a little digging about cataching exceptions.
According to this question (C++ catching all exceptions) one of the answers states:
[catch(...)] will catch all C++ exceptions, but it should be considered bad design.
At the…

Andrew Truckle
- 17,769
- 16
- 66
- 164
0
votes
0 answers
MFC CRecordSet snapshot support (is missing?) after migration from VC6 to VS2019
We made a migration our old (>20 years) project from VC6 to VS2019 (v142).
Everything is working well, except one unpleasant thing: our CRecordSet objects act now in dynaset mode. As result: super slow working on poor connection. Because dynaset…

Sergey Alikin
- 159
- 10
0
votes
0 answers
Using CDatabase to open a ACCDB file is displaying a Select Database Source window
I have a CDatabase.
One of my users has Access 2021 x64 installed. He runs the 64 bit edition of my software.
It opens a database like this:
CString strDBConnectString = L"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=

Andrew Truckle
- 17,769
- 16
- 66
- 164
0
votes
0 answers
Why does this cause an exception when I open a CDatabase (ACCDB)
Sample project:
https://www.dropbox.com/s/ezwe48gpezrr19u/MFCApplicationDB.zip?dl=0
I am using VS 2022. Has basic code in the dialogs OnInitDialog:
CDatabase db;
if (db.OpenEx(_T("Driver={Microsoft Access Driver (*.mdb,…

Andrew Truckle
- 17,769
- 16
- 66
- 164
0
votes
1 answer
Compacting Microsoft Access Database without using DAO
I use the CDatabase class to open a ACCDB Access database. The driver is: _T("Microsoft Access Driver (*.mdb, *.accdb)").
I can open and use the database OK (have done so for many years):
if (DatabaseExist(m_strMDBPath))
{
// AJT v10.5.0 Take…

Andrew Truckle
- 17,769
- 16
- 66
- 164
0
votes
0 answers
How to retrieve records from MS ACCESS database file in MFC using CRecordset::GetFieldValue
Please, I am having problems with getfieldvalue, if I use single quotes on the first arguments, it compile without errors, but it does not display database contents, at run time it gives me; Database error: Incorrect field name or field index , if I…
0
votes
0 answers
Get excel file sheet names using CDatabase/ODBC driver
I am using OBDC to import data from some excel file using CDatabase and and excel drivers.
Code is something like this:
CString GetExcelDriver()
{
TCHAR szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
TCHAR *pszBuf = szBuf;
…

Harsh Shankar
- 506
- 5
- 16
0
votes
0 answers
ODBC Connection via CDatabase fails with connection string from previous succesfull connection
I'm a bit clueless at the moment what the problem is with this code.
It trows a exception of type CDBException when trying to connect with the given ODBC Connect String and never comes back from .OpenEx - the lower message boxes never display.
There…

Idenwen
- 13
- 4
0
votes
1 answer
Microsoft Jet BIT Fields
I am using MFC to manage Microsoft Access databases usingCDatabase. I support both mdb and accdb formats.
My understanding of BIT fields is:
0 or Null is False or No
-1 is True or Yes
Is this always the case? Values of -1 and 0?
Thanks.

Andrew Truckle
- 17,769
- 16
- 66
- 164
0
votes
0 answers
How to change the password of a CDatabase object from afxdb.h using C++?
I can successfully open a password-protected mdb database using:
CDatabase::Open(NULL, FALSE, FALSE, lpszConnect, FALSE);
where lpszConnect = "ODBC;DRIVER={Microsoft Access Driver (*.mdb,…

W. Stalin R.
- 81
- 1
- 8
0
votes
1 answer
Connect to oracle server using CDatabase from MFC
I try to connect to a oracle database, where server is installed on my laptop and run on port 1521 and the name is "orcl". First, I connect using Java and jdbc using this code:
private static final String URL =…

Livinti Cosmin
- 1
- 1
0
votes
0 answers
Importing excel files using CDatabase
Early, I uses DAO to import excel files in MFC application, like this:
CDaoDatabase base1;
base1.Open(mfile, FALSE, FALSE, "Excel 5.0;");
After last windows updates this does not works. Is there correct way to import Excel files using ODBC…

Сергей Соколов
- 349
- 4
- 14
0
votes
1 answer
MFC can't load error string resources in dbcore.cpp
I have an old MFC application I've recently updated to include code that uses CDatabase to access an old MDB.
This works, but when an internal error occurs, I get an assertion in dbcore.cpp that it could not load the error string resource.
After…

Jonathan Wood
- 65,341
- 71
- 269
- 466
0
votes
2 answers
Return instance causes 'attempting to reference a deleted function' error
After working with C# for the past decade or two, my C++ is getting a little rusty.
I'm writing a database class and have an issue with the following method:
CRecordset CAccessDatabaseReader::ExecuteSqlQuery(LPCTSTR pszSqlQuery)
{
CRecordset…

Jonathan Wood
- 65,341
- 71
- 269
- 466