CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    2

    About SQLConfigDataSource

    Hi,
    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());

    Thanks

  2. #2

    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.

    --
    http://savensearch.blogspot.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured