ODBC-Excel data truncated

27/07/2006 - 21:08 por Gustav Holst | Informe spam
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

#1 Héctor Miguel
28/07/2006 - 04:57 | Informe spam
hi, Gustav !

AFAIK, what -mostly- applies to ODBC-Data Truncated 'errors/solutions' are the following KB-articles:

Data Truncated to 255 Characters with Excel ODBC Driver (Rows To Scan)
http://support.microsoft.com/defaul...US;Q189897

SQLExecQuery and SQLRequest Limited to 255 Characters
http://support.microsoft.com/defaul...US;Q114992

if any doubt [or additional info]... would you please let us know ?

hth,
hector.

__ original post __
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?

Preguntas similares