OleDbException: Too many fields defined.

  • Thread starter Thread starter Ranier Dunno
  • Start date Start date
R

Ranier Dunno

Hi,

I'm using an Excel-file generated by a third-party
application as input to my C# app. The problem occurs in
one of the worksheets in that Excel-file, where there is
a single column and no column name, so that the data
starts in the second row.

I'm connecting to the Excel-file as an OleDb-source,
using an OleDbDataAdapter to fill a DataTable. It works
fine for the other worksheets, but for this one, I get an
OleDbException when I try to fill the DataTable. The
exception message is 'Too many fields defined'. Does
anyone know this message, and how to avoid it?
 
-----Original Message-----
Hi,

I'm using an Excel-file generated by a third-party
application as input to my C# app. The problem occurs in
one of the worksheets in that Excel-file, where there is
a single column and no column name, so that the data
starts in the second row.

I'm connecting to the Excel-file as an OleDb-source,
using an OleDbDataAdapter to fill a DataTable. It works
fine for the other worksheets, but for this one, I get an
OleDbException when I try to fill the DataTable. The
exception message is 'Too many fields defined'. Does
anyone know this message, and how to avoid it?
.

Found it myself, apparently the sheet had lots of empty
columns going, crashing with a maximum number of columns
for the OleDb connection or something.
 
Ranier -

This is probably not related to the issue of not having a field name. Based
on the error you're getting, you may want to check and make sure that the
columns in the worksheet that seem empty aren't filled with " " or non-print
chars. There is a hard limit to how many columns can be defined.

Try coping just that column to another worksheet and parsing that. If that
works, you know it's other columns. (perhaps column KT has something in it,
or something like that?)

-Philip
 
Back
Top