Excel file and oledb

  • Thread starter Thread starter messageman
  • Start date Start date
M

messageman

hi

I have the following code:

OleDbDataAdapter oleCmd = new OleDbDataAdapter("SELECT [Customer ID],
[Customer #], [Company], [Location] FROM [Sheet1$]", oleConn);

DataSet oDS = new DataSet();
oleCmd.Fill(oDS);

The connection string is perfect. no problem with that.

It ran very good until I got this file from the client. though it has
the same format and same alignment and same sheet number and etc., my
program would fail at the FILL line number.
the exception is
System.oledb.OledbException: No value given for one or more required
parameters.

Now comes the interesting part. if i SELECT ALL from this file and
copy and paste it in a new Excel file, and run my program it runs
Perfect as it is supposed to run.

what might have caused the problem ????
I checked the file, its the same data, no extremities.
is there some different format in the file i received, or if so how to
go about avoiding it. ??

please help.

thanks
messageman
 
Messageman,

Did you it also in between
OleDbDataAdapter oleCmd = new OleDbDataAdapter("SELECT Customer ID,
Customer, Company, Location FROM [Sheet1$]", oleConn);

And than just delete a column, everytime you get the error than you know
witch it is when you do not get the error.

I hope this helps?

Cor
 
hi,

thanks for the help. After a lot of time, and debugging the code by
deleting several possible combinations of columns, I found out that
its 3 columns that are causing the problem.

If i run the program by deleting those columns, then it runs fine when
i put them back it causes the exception.

I found out the error, i dont know what causes this error ??? and how
to resolve it.??

help is appreicated.

-messageman
 
On 10 Oct 2004 13:37:00 -0700, (e-mail address removed) (messageman) wrote:

¤ hi,
¤
¤ thanks for the help. After a lot of time, and debugging the code by
¤ deleting several possible combinations of columns, I found out that
¤ its 3 columns that are causing the problem.
¤
¤ If i run the program by deleting those columns, then it runs fine when
¤ i put them back it causes the exception.
¤
¤ I found out the error, i dont know what causes this error ??? and how
¤ to resolve it.??
¤
¤ help is appreicated.

Does the Worksheet have column headers and are the column names you are referencing in your SQL
statement present in the column headers?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top