Link to home
Start Free TrialLog in
Avatar of shraddha_brains
shraddha_brains

asked on

Reading Excel data conditionally using ADO

I m tring to read data from an excel sheet conditionally. for eg i want to read all fields from the excel sheet where the date is '4/4/2004' or may be greater than or lesser than that date . I am unable to do so.

I m using ADO.

the query i m using is "select * from [ESTROCIT$] where oc_no=38 and oc_dt = '4/12/2004'"

but the error i get is  "Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression."

could ne one give me ne pointers?
ASKER CERTIFIED SOLUTION
Avatar of zastil
zastil

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You will get that error if all the cols you are searching by are not the same datatype. Ie if the date col has some blanks or text in the first 8 rows it does not see it as a data and so will return errors like you have above.

Try this first to see if you get the error:
"select * from [ESTROCIT$] where oc_no=38"
then
"select * from [ESTROCIT$] where oc_no='38'"
etc, extend it up then to see if it is the date...
Avatar of shraddha_brains
shraddha_brains

ASKER

Thanks zastil. the answer seems so easy. :-) my code now works fine

HI slim shaneey, thanks for ur thoughful answer. i did check accordingly and things were all right. ne ways the code worked fine with zastil's suggestion.

thanks all.