VC下用DAO连接数据库遇到的问题
Eason 2001-08-14 10:01:53 我写一个数据库程序,用mfc wizard创建一个包含数据库头文件的sdi程序。
在程序中我写了如下程序
void CMyDAODoc::OnEditCopy()
{
//CDaoDatabase *MyDb = new CDaoDatabase();
CDaoDatabase MyDb;// = new CDaoDatabase();
try
{
MyDb.Open("",FALSE,FALSE,_T("ODBC;DSN=safe;UID=admin;PWD=adfa"));
//MyDb.Open("D:\\workshop\\ServerMonitor\\DAOTest\\safe.mdb",FALSE,FALSE,_T(""));
}catch(CDaoException *e)
{
TCHAR szCause[255];
CString strFormatted;
e->GetErrorMessage(szCause,255);
AfxMessageBox(szCause);
}
CDaoRecordset *MySet = new CDaoRecordset(&MyDb);
try
{
//MySet->Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM ab");
}catch(CDaoException *e)
{
TCHAR szCause[255];
CString strFormatted;
e->GetErrorMessage(szCause,255);
AfxMessageBox(szCause);
}
}
显示如下错误
You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database.
这是什么原因?哪位高手给指点一下