If you use Excel file in ADO, you cannot delete the line.

Asked 2 years ago, Updated 2 years ago, 297 views

C++ is using ADO to add, search, and update lines for Excel files.I can't just delete it.Is there such a restriction when I specify Excel files in ADO?Cannot identify error.

CSstring strFile=_T("C:\\temp\\sample.xlsx");
CStrings;
try
{
 CSstring strCon;
 strCon.Format(_T("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=%s; Extended Properties=Excel 12.0xml"), strFile);
 con.CreateInstance(__uuidof(Connection)));
 con->Open(_bstr_t(strCon), '' , '' , adConnectUnspecified);

 _RecordsetPtrrs;
 rs.CreateInstance(__uuidof(Recordset)));
 rs->CursorLocation=adUseClient;
 rs->Open(_variant_t("SELECT* FROM [test$] WHERE [ID] = 'A1' ), con.GetInterfacePtr(), adOpenForwardOnly, adLockOptimistic, adCmdText);

 if(!rs->GetadoEOF())
 {
  rs->Delete (adAffectCurrent);
  rs->Close();
 }
}
catch(_com_error&e)
{
 s=e.ErrorMessage();
}

c++ excel mfc

2022-09-30 21:51

1 Answers

Unfortunately, your Microsoft.ACE.OLEDB.12.0 has been distributed, but no documentation has been provided, so I can only say that I don't know how it behaves.

The MDAC of the predecessor of this ? is already scattered documents.Microsoft Excel Driver Programming Consultations/Read-Only Status (Excel Driver)

It is possible to update values when using the Microsoft Excel driver, but can't be deleted from a table based on a Microsoft Excel spreadsheet, so updates are not considered officially supported by the Microsoft Excel driver.

said he.ACE has taken over the same specification, and line deletion is not supported.


2022-09-30 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.