Click to See Complete Forum and Search --> : CDaoRecordset


dfageko
April 3rd, 2003, 08:16 PM
Hi!
I have a question about the MFC CDaoRecordset class. I am having some trouble with it and I hope someone out there might know the answer to my question! (Pleeeeaase!) Let me describe the problem... First, I'd like to explain what error I'm getting and then describe a bit how my program is implemented. I'm getting the following error when I do a file-open using CDaoRecordset.open() function call (I do have an SQL statement inside), "The Micorosft Jet Database engine cannot find the input table of query 'Entries'. Make sure it exists and that its name is spelled correctly." The weird thing is, if I do a file-new, everything is fine! I have no idea why...
Let me give you more detail about the actual program now. In my doc class, I have two pointers CDaoDatabase and DaoRecordset. I have two virtual functions that take care of OnNewDocument and OnOpenDocument. Here is an example code from my OnOpenDocument class. It is almost the same as the one from my OnNewDocument virtual function.
I am trying to open an Access database. DB_FILENAME is a constant I declared in my .h file. Actually, what I found was this. There's a problem with the database connection everytime I serialize. It could be save or open. I tried using an ODBC connection instead of a DAO connection, and I'm getting the same error message, "The Micorosft Jet Database engine cannot find the input table of query 'Entries'. Make sure it exists and that its name is spelled correctly."

If I don't serialize, I have no problem. Any ideas? Does serialization screw up a database connection?


if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;

if (db != NULL) {
if (db->IsOpen())
db->Close();
delete db;
}
db = new CDaoDatabase;

ASSERT_VALID(db);


if (recset != NULL) {
if (db->IsOpen())
recset->Close();
delete recset;
}

db->Open(DB_FILENAME);

recset = new CDaoRecordset(db);
ASSERT_VALID(recset);

recset->Open(AFX_DAO_USE_DEFAULT_TYPE, "SELECT * FROM Entries");

The error stems from the last line of the code.

Thanks!!!
dfageko