populating dataset from excel range, error where no data.

  • Thread starter Thread starter Winshent
  • Start date Start date
W

Winshent

My web app allows users to upload an excel file and then ado.net loads
the data (if there is any) into sql server.

I have a problem when if there is no data in the excel spread
(completed on a weekly basis), then the code fails when i try to fill
the data adapter with the dataset.

should this fail?

whats the best way to deal with this? just simply do a count on the
dataset?
 
On 29 Nov 2004 07:41:05 -0800, (e-mail address removed) (Winshent) wrote:

¤ My web app allows users to upload an excel file and then ado.net loads
¤ the data (if there is any) into sql server.
¤
¤ I have a problem when if there is no data in the excel spread
¤ (completed on a weekly basis), then the code fails when i try to fill
¤ the data adapter with the dataset.
¤
¤ should this fail?
¤
¤ whats the best way to deal with this? just simply do a count on the
¤ dataset?

Worksheets that are blank typically contain a single column (F1) and row so if you attempt to
reference other columns an exception will be generated.

What you could do is check the column count (assuming more than one is expected) in order to
determine whether the Worksheet is blank.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
I suppose you are using ODBC.NET to pull data from excel
file. It automatically recognizes the first row data in
Excel sheet as column name. So for both one row and blank
worksheet the filled Data table will have 0 row count.

Elton Wang
 
Back
Top