我需要读取FoxPro Dbf文件并在c ++中重新创建它;我安装了foxpro驱动程序版本9.0但它没有出现在Windows DSN的驱动程序列表中。然后我从visual studio 6 setup安装了foxpro,并在那里显示了驱动程序,我可以通过ADO使用它进行连接。问题是
_ConnectionPtr m_pCon;
_RecordsetPtr m_pRecordset;
AfxOleInit();
_bstr_t bt1(PassedCstringDirectory);//PassedCstringDirectory passed as argument
_bstr_t bt(sqlcmd);//sqlcmd passed as argument
m_pCon.CreateInstance(__uuidof(Connection));
HRESULT hr;
VARIANT *rowseffected=NULL;
try
{
//The SourceDB should be a proper directory
hr=m_pCon->Open("Provider=VFPOLEDB; SourceType=DBF; "
"SourceDB="+bt1+";Extended Properties=FoxPro 3.0;", "","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox("Connection failed, check the direction!");
}
m_pCon->Execute(bt,rowseffected,adConnectUnspecified);
m_pCon-> Execute()返回false(S_FALSE)但正在创建文件(dbf和fpt)。我无法将数据插入文件。错误是。“当前Recordset不支持更新。可能是提供者或所选锁类型的限制。“