March 20th, 2013, 04:54 PM
I used SQLConfigDataSource to create a MS Access file, it works fine. But, right after the creation of the file, I want to create a session to it using CDataSource::Open. The code to open a Database works fine with a database already created, but if I try to open a database that has just been created with SQLConfigDataSource, it fails.
So, right after the creation with SQLConfigDataSource, I tried to open manually the database by double-clicking on it and it said that the database is already in use. So, I think that's the reason why I can't open it with DataSource::Open.
But, the database created is not used by anybody.
So,when I use this code, is there a close() function or something similar I should use, I cannot find it.
BOOL created = SQLConfigDataSource(NULL, ODBC_ADD_DSN, L"Microsoft Access Driver (*.mdb)", createPath.c_str());
March 22nd, 2013, 06:57 PM
Re: About SQLConfigDataSource
If its in a local function, it probably goes out of scope, with the still open db - the thread that created the db never closed it. Try setting it to null before the function ends and use normal OLEDB functions to open and read the db in another function.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!