|
-
May 1st, 1999, 09:48 AM
#1
CDoaRecordSet Problems
HI There
I have been working on connecting to an Access database through DAO. What I have done so far is under InitInstance I have opened a connection to the database through CDaoDatabase OPEN() I did this so that the database is open globally. The code compiles and runs fine with this. Then what I have done is under the OnInitialUpdate I have opened the database with CDoaRecordSet OPEN(). This part of the program seems to crash the program. The error message I get is that it can't open the data.
Below I have the code for the two sections.
Any suggestions would be really appreciated
Thanks in advance
//under the InitInstance
CdaoDatabase db;
try
{
db.Open("C:\\mydata.mdb",FALSE,FALSE,_T(""));
}
catch (CDaoException *e)
{
//db = NULL;
TCHAR szCause[255];
CString strFormatted= _T("the file could not be Opened");
e->GetErrorMessage(szCause,255);
strFormatted += szCause;
AfxMessageBox(strFormatted, MB_OK | MB_ICONEXCLAMATION);
e->Delete();
//m_bFileOpen = FALSE;
//return FALSE;
throw;
}
//CdoaRecordSet Cdata7bNameSet;
//under OnIntialUpdate();
CData7bApp *app =(CData7bApp*) AfxGetApp();
CData7bNameSet nameSet(&(app->db)); // it is good till this point
nameSet.Open(AFX_DAO_USE_DEFAULT_TYPE,FALSE,0);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|