Cannot Update Excel File
- From: "FrankNatoli" <FrankJNatoli@xxxxxxxxxxxxx>
- Date: 26 Dec 2006 19:35:41 -0800
Sorry if this is the millionth time for this particular question, but a
search did not find an appropriate match. Can read Excel file with ODBC
w/o problem. Cannot update same Excel file. Both CDatabase.CanUpdate()
and CRecordSet.CanUpdate() report read only. This is despite
READONLY=FALSE in OpenEx string. I see comments in the literature and
this forum regarding the need for a unique key, but isn't a row number
in Excel fundamentally a unique key? Or does a special column need to
be implemented in a spread***? If so, what kind of column?
For reference, here is my code:
CString sDsn;
sDsn.Format(_T("DRIVER={%s};DSN='';DBQ=%s;ReadOnly=FALSE"),
m_pszDriverName, m_dbPath);
TRY
{
// open database
database.OpenEx(sDsn, CDatabase::noOdbcDialog);
if (database.CanUpdate())
AfxMessageBox(_T("database can update"));
else
AfxMessageBox(_T("database cannot update"));
// Allocate the recordset
CRecordset recset(&database);
CString sSql = _T("SELECT * FROM Attendance");
// Execute that query (implicitly by opening the recordset)
recset.Open(CRecordset::dynaset, sSql, CRecordset::none);
if (recset.CanUpdate())
AfxMessageBox(_T("recordset can update"));
else
AfxMessageBox(_T("recordset cannot update"));
}
CATCH(CDBException, e)
{
}
Thanks.
.
- Prev by Date: Strange behaviour with SQLBulkOperations
- Next by Date: RE: Strange behaviour with SQLBulkOperations
- Previous by thread: Strange behaviour with SQLBulkOperations
- Index(es):