我在vc中用Ado的recordset.save方法保存了一个xml文件,然后去open
代码如下
try
{
m_piRecordSet.CreateInstance(__uuidof(Recordset));
m_piRecordSet->Open("authors.xml","Provider=MSPersist;",
adOpenForwardOnly,adLockOptimistic,adCmdFile);
m_piRecordSet->Find("au_lname = 'Carson'",NULL,adSearchForward);
if (m_piRecordSet->EndOfFile)
{
printf("Name not found ...\n");
m_piRecordSet->Close();
return;
}
m_piRecordSet->GetFields()->GetItem("City")->PutValue("Berkeley");
m_piRecordSet->Update();
// Save changes in ADTG format this time, purely for sake of
// illustration. Note that the previous version is still on the
// diskette as a:\Pubs.xml.
m_piRecordSet->Save("Pubs.agdt",adPersistADTG);
m_piRecordSet->Close();
}
成功,然后如下:
try
{
m_piRecordSet.CreateInstance(__uuidof(Recordset));
//m_piConnection->Open(strCnn,"","",NULL);
//If there is no ActiveConnection, you can open with defaults.
m_piRecordSet->Open("Pubs.agdt","Provider=MSPersist;",
adOpenForwardOnly,adLockOptimistic,adCmdFile);
//Connect to the database, associate the Recordset with
//the connection, then update the database table with the
//changed Recordset.
m_piRecordSet->PutActiveConnection(_variant_t((IDispatch *)m_piConnection));
m_piRecordSet->UpdateBatch(adAffectAll);
m_piRecordSet->Close();
m_piConnection->Close();
}
在UpdateBatch(adAffectAll)后整个程序都没问题,可就是我到数据库里查找的时候,数据库内容根本没变话,开始我还以为没有commit,可commit后还是老样子,各位大侠帮忙看看....多谢了
代码如下
try
{
m_piRecordSet.CreateInstance(__uuidof(Recordset));
m_piRecordSet->Open("authors.xml","Provider=MSPersist;",
adOpenForwardOnly,adLockOptimistic,adCmdFile);
m_piRecordSet->Find("au_lname = 'Carson'",NULL,adSearchForward);
if (m_piRecordSet->EndOfFile)
{
printf("Name not found ...\n");
m_piRecordSet->Close();
return;
}
m_piRecordSet->GetFields()->GetItem("City")->PutValue("Berkeley");
m_piRecordSet->Update();
// Save changes in ADTG format this time, purely for sake of
// illustration. Note that the previous version is still on the
// diskette as a:\Pubs.xml.
m_piRecordSet->Save("Pubs.agdt",adPersistADTG);
m_piRecordSet->Close();
}
成功,然后如下:
try
{
m_piRecordSet.CreateInstance(__uuidof(Recordset));
//m_piConnection->Open(strCnn,"","",NULL);
//If there is no ActiveConnection, you can open with defaults.
m_piRecordSet->Open("Pubs.agdt","Provider=MSPersist;",
adOpenForwardOnly,adLockOptimistic,adCmdFile);
//Connect to the database, associate the Recordset with
//the connection, then update the database table with the
//changed Recordset.
m_piRecordSet->PutActiveConnection(_variant_t((IDispatch *)m_piConnection));
m_piRecordSet->UpdateBatch(adAffectAll);
m_piRecordSet->Close();
m_piConnection->Close();
}
在UpdateBatch(adAffectAll)后整个程序都没问题,可就是我到数据库里查找的时候,数据库内容根本没变话,开始我还以为没有commit,可commit后还是老样子,各位大侠帮忙看看....多谢了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货