Hi!
I have an Excel file that I'm reading using ODBC and MFCs in visual C++6.
I make:
1) Database open as:
sSql.Format(L"DRIVER={%ls};MAXSCANROWS=0;DBQ=%ls;", sDriver,
sExcelFile);
if( m_XlsDB.OpenEx(sSql, CDatabase::openReadOnly |
CDatabase::noOdbcDialog) == 0 ) return -1;
m_XlsDB is a CDatabase MFC object.
2) Open a recordset as:
CString sSql = L"SELECT "+ m_Fields +" FROM "+ pXlsName;
if ( m_Rs.Open(CRecordset::forwardOnly, sSql,
CRecordset::readOnly) )
Then I iterate through the recordset using "MoveNext()"
All right, but sometimes it throws the exception "Data Truncated". But in
the derived CRecordset class, in method "DoFieldExchange()" I use RFX
functions correctly, that is I indicate the max. length of the fields:
RFX_Text(pFX, strFldName, str, 2000);
(there isn't any fields in the Excel file with more than 2000 characters).
Another tip is that the cells are written in french, but I'm Spanish. The
Visual C++ program, for avoid problems on reading the excel, is an Unicode
program (UNICODE macro defined).
Any ideas?
Leer las respuestas