Need help with closing database.

Accessing ODBC-dbase in Visual C++, having trouble closing database.
I have tried the following:

1. CDatabase db;
   db.Close(); // Has no effect on database.

2. CTestSet ts;
   ts.Close(); // error message when executed:
                              "Debug Assertion Failed!"

3. CRecordset rs;
   rs.Close(); // error message when executed:
                               "Debug Assertion Failed!"

Please Help.
rgcommAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

R U closing without opening the database?...

Just try

if(rs.IsOpen())
rs.Close();


VinExpert
0
inprasCommented:
Hi
1. CDatabase db;
   db.Close();
Since default declaration no assertion hence no error no effect.

2. CTestSet ts;
   ts.Close();
Assertion because U have not opened it

3. CRecordset rs;
   rs.Close();
Assertion because U vave not opened it

If U want to close a databse U have to close all the recordsets associated and then close the database.
0
rgcommAuthor Commented:
The file is still open, see code:

testSet.cpp

CString CTestSet::GetDefaultConnect()
{  
   return _T("ODBS;DSN=TestDB");
}

CString CTestSet::GetDefaultSQL()
{
    return _T("[TESTFILE]");
}

testView.cpp

Cdatabase db;
CRecordset rs;
CTestSet ts;

// TESTFILE is Open at this point

void CTestView::OnButton1()
{
    if(rs.IsOpen())
       rs.Close();
    if(ts.IsOpen())
       ts.Close();
    if(db.IsOpen())
       db.Close();
}    

// TESTFILE is still Open after Button 1

Thank you for your help
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

inprasCommented:
What do U mean Open?
0
inprasCommented:
I don't see any rs.Open() here? how come it is open if U R not openeing it?
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Where r u opening it?. Without opening u r tryin gto close it. so it gives assertion. With IsOpen() check does it giving the assertion?

VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgcommAuthor Commented:
When I executed the program it locked up the database just from the GetdefaultConnect & GetdefaultSQL without using the open function.

It's a dbase (.dbf) problem. As soon as I switched the data over to Access (.mdb) the problem was solved.
0
rgcommAuthor Commented:
I did not have a open function, dbase (.dbf) opened the file at execution and would not allow me to close.

I imported the data into Access (.mdb) and now everything is working fine.

Thank you again for all your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.