|
Please see the original code:
BOOL CMyApp :: InitInstance ()
{
...
AfxOleInit ();
pConn.CreateInstance (__ uuidof (Connection));
try
{
pConn-> Open ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = ki.mdb", "", "", adModeUnknown);
}
catch (_com_error e)
{
AfxMessageBox ("Database connection failed, confirm whether the database POP.mdb is in the current path!");
return false;
}
return FALSE;
}
extern CMyApp theApp;
void Show ()
{
CString str;
str = "select * from Name";
_RecordsetPtr m_pRs;
Ranch
try
{
m_pRs = theApp.pConn-> Execute ((_ bstr_t) str, NULL, adCmdText);
}
catch (_com_error e)
{
AfxMessageBox (e.ErrorMessage ());
}
catch (...)
{
AfxMessageBox ("Error opening dataset 1!");
}
Ranch
}
After running: "Invalid pointer" error displayed |
|