Solved

Reading Excel data conditionally using ADO

Posted on 2004-04-13
3
440 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:shraddha_brains
3 Comments
 
LVL 3

Accepted Solution

by:
zastil earned 50 total points
Comment Utility
Not sure but try replacing ' with #

i.e. "select * from [ESTROCIT$] where oc_no=38 and oc_dt = #4/12/2004#"
0
 
LVL 11

Expert Comment

by:Slimshaneey
Comment Utility
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...
0
 

Author Comment

by:shraddha_brains
Comment Utility
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now