Solved

Reading Excel data conditionally using ADO

Posted on 2004-04-13
3
480 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
ID: 10811888
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
ID: 10811942
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
ID: 10812137
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set time on Session (ASP) 14 29
ASP and Extracting XML 7 24
Html split(text) 2 26
StoredProcedure to JSON query faulty syntax 2 22
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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