VC怎样操作Paradox数据库呢?
因为要适应某只能识别Paradox数据库文件的软件,要创建Paradox数据库文件。
我偿试使用Ado,但只能读取数据,写入就出错。
CString sPath = _T("D:\\XYZ");
CString ConnectionString;
ConnectionString.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s; Extended Properties=Paradox 5.x;Persist Security Info=False"), sPath);
_ConnectionPtr m_pDb;
_RecordsetPtr m_pRecordset;
AfxOleInit();
try
{
m_pDb.CreateInstance(__uuidof(Connection));
m_pDb->Open(ConnectionString.AllocSysString(),"","",adModeUnknown);
}
catch(_com_error &e)
{
AfxMessageBox(e.Description());
return;
}
CString sFile = _T("2111.DB");
ConnectionString.Format(_T("select * from %s"), sFile);
m_pRecordset.CreateInstance(_uuidof(Recordset));
try
{
m_pRecordset->Open(ConnectionString.AllocSysString(),(IDispatch*)m_pDb,adOpenDynamic,adLockOptimistic,adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
return;
}
try
{
m_pRecordset->MoveFirst();
m_pRecordset->Move((long)(2));
m_pRecordset ->PutCollect((long)(2), "2222"); //这里出错
m_pRecordset ->Update();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
m_pRecordset->Close();
m_pDb->Close();
VC有专门针对Paradox数据库的操作方法吗?