473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access 2K query returns different results when run in code than whenrun manually

When run manually, my query appends 14 records. When run from code using
CurrentProject.Connection.Execute, the same query appends 11 records.

Does anyone have an explanation of why this could be happening? I have
tried the ADO 2.1 and 2.7 libraries.

TIA

Nov 12 '05 #1
8 2141
You positive it's exactly the same query? Are you definitely running it
against the same database both times?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Bruce Dodds" <br********@comcast.net> wrote in message
news:MCPqc.78653$536.12973485@attbi_s03...
When run manually, my query appends 14 records. When run from code using
CurrentProject.Connection.Execute, the same query appends 11 records.

Does anyone have an explanation of why this could be happening? I have
tried the ADO 2.1 and 2.7 libraries.

TIA

Nov 12 '05 #2
Douglas J. Steele wrote:
You positive it's exactly the same query? Are you definitely running it
against the same database both times?

Yes, I'm sure.

Nov 12 '05 #3
CDB
1. A bug in ADO?
2. The queries are not identical.
3. There is a difference in behaviour between ADO and the Query Wizard.
There -are- differences: eg the query builder packs extra smarts, resolving
matters that will not be resolved with straight SQL. Parameters, for
example.

It sure would be enlightening to see the SQL...

Clive
"Bruce Dodds" <br********@comcast.net> wrote in message
news:qUTqc.81730$xw3.4570715@attbi_s04...
Douglas J. Steele wrote:
You positive it's exactly the same query? Are you definitely running it
against the same database both times?

Yes, I'm sure.

Nov 12 '05 #4
CDB wrote:
1. A bug in ADO?
2. The queries are not identical.
3. There is a difference in behaviour between ADO and the Query Wizard.
There -are- differences: eg the query builder packs extra smarts, resolving
matters that will not be resolved with straight SQL. Parameters, for
example.

It sure would be enlightening to see the SQL...


OK.

The application selects Fedex shipments from a table of purchase
transactions and puts them into Fedex address book format.

There are two queries. A select query selects the records and sets a
flag if there is a separate Ship To address. An append query takes that
as input, does some reformatting, and adds the records to an output
table. (The append query calls a user-written function to validate phone
numbers. This has nothing to do with the problem, however, since the
results don't change if the function is removed.)

FWIW, the only records that are dropped from the append when it is
executed from code are the ones that have "USA" in the Country field. So
the difference between the manual and automated query processing may be
in the handling of 'Like "US*"'.

Select query - qrySelectApexFedex

SELECT [Order Number], [Customer Name], [First Name], [Last Name],
Title, [Company Name], [Address 1], [Address 2], City, State, Zip,
Phone, Country, Email, [Ship To], [Ship Title], [Ship First Name], [Ship
Last Name], [Ship Company], [Ship Address 1], [Ship Address 2], [Ship
City], [Ship State], [Ship Zip], [Ship Country], [Ship Phone],
IIf(Len([Ship To])>0,True,False) AS TestShipTo
FROM [Apex Fedex]
WHERE (((Country) Like "US*" Or (Country)="United States" Or
(Country)="Canada" Or (Country)="CA") AND (([Ship To]) Is Null) AND
((([State])="HI" Or ([State])="AK" Or ([State])="PR" Or
([State])="VI")=False)) OR ((([Ship Country]) Like "US*" Or ([Ship
Country])="United States" Or ([Ship Country])="Canada" Or ([Ship
Country])="CA") AND ((([Ship State])="HI" Or ([Ship State])="AK" Or
([Ship State])="PR" Or ([Ship State])="VI")=False));

Append query - qryAppendFedex

INSERT INTO tblApexFedex ( Nickname, FullName, FirstName, LastName,
Title, Company, AddressOne, AddressTwo, City, State, Zip, PhoneNumber,
CountryCode, EmailAddress, ReferenceDescription )
SELECT qrySelectApexFedex.[Customer Name], IIf([TestShipTo]=True,[Ship
To],[Customer Name]) AS FullName, IIf([TestShipTo]=True,[Ship First
Name],[First Name]) AS FirstName, IIf([TestShipTo]=True,[Ship Last
Name],[Last Name]) AS LastName, IIf([TestShipTo]=True,[Ship
Title],[Title]) AS FindTitle, IIf([TestShipTo]=True,[Ship
Company],[Company Name]) AS CompanyName, IIf([TestShipTo]=True,[Ship
Address 1],[Address 1]) AS Address1, IIf([TestShipTo]=True,[Ship Address
2],[Address 2]) AS Address2, IIf([TestShipTo]=True,[Ship City],[City])
AS FindCity, IIf([TestShipTo]=True,[Ship State],[State]) AS FindState,
IIf([TestShipTo]=True,[Ship Zip],[Zip]) AS FindZip,
GetPhone([Phone],[Ship Phone]) AS PhoneIn, IIf(UCase([Country]) Like
"CA*","CA","US") AS CountryCode, qrySelectApexFedex.Email,
qrySelectApexFedex.[Order Number]
FROM qrySelectApexFedex;


Nov 12 '05 #5
Bruce Dodds <br********@comcast.net> wrote in
news:lV0rc.84617$xw3.4719094@attbi_s04:
FWIW, the only records that are dropped from the append when it is
executed from code are the ones that have "USA" in the Country
field. So the difference between the manual and automated query
processing may be in the handling of 'Like "US*"'.


Is the back end a Jet MDB? Or a server database?

If the former, why the hell are you bothering with ADO?

If the latter, why are you using Jet's wildcard operator instead of
"%"?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #6
David W. Fenton wrote:
Bruce Dodds <br********@comcast.net> wrote in
news:lV0rc.84617$xw3.4719094@attbi_s04:

FWIW, the only records that are dropped from the append when it is
executed from code are the ones that have "USA" in the Country
field. So the difference between the manual and automated query
processing may be in the handling of 'Like "US*"'.

Is the back end a Jet MDB? Or a server database?

If the former, why the hell are you bothering with ADO?

If the latter, why are you using Jet's wildcard operator instead of
"%"?


The back end is Jet. I'm using ADO because I generally use DAO, and want
to get more experience with ADO. This is a pretty trivial application.

Getting rid of "Like" did fix the problem.

Nov 12 '05 #7
Bruce Dodds <br********@comcast.net> wrote in
news:Kr5rc.84001$536.13973775@attbi_s03:
David W. Fenton wrote:
Bruce Dodds <br********@comcast.net> wrote in
news:lV0rc.84617$xw3.4719094@attbi_s04:
FWIW, the only records that are dropped from the append when it
is executed from code are the ones that have "USA" in the Country
field. So the difference between the manual and automated query
processing may be in the handling of 'Like "US*"'.
Is the back end a Jet MDB? Or a server database?

If the former, why the hell are you bothering with ADO?

If the latter, why are you using Jet's wildcard operator instead
of "%"?


The back end is Jet. I'm using ADO because I generally use DAO,
and want to get more experience with ADO. . . .


Why do you want to get more experience with a technology that is
just as much of a dead end as DAO?
Getting rid of "Like" did fix the problem.


But it then wouldn't be the same query.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #8
David W. Fenton wrote:
Bruce Dodds <br********@comcast.net> wrote in
news:Kr5rc.84001$536.13973775@attbi_s03:

David W. Fenton wrote:

Bruce Dodds <br********@comcast.net> wrote in
news:lV0rc.84617$xw3.4719094@attbi_s04:
FWIW, the only records that are dropped from the append when it
is executed from code are the ones that have "USA" in the Country
field. So the difference between the manual and automated query
processing may be in the handling of 'Like "US*"'.

Is the back end a Jet MDB? Or a server database?

If the former, why the hell are you bothering with ADO?

If the latter, why are you using Jet's wildcard operator instead
of "%"?
The back end is Jet. I'm using ADO because I generally use DAO,
and want to get more experience with ADO. . . .

Why do you want to get more experience with a technology that is
just as much of a dead end as DAO?


I thought I might run into ADO while working with systems developed
elsewhere, or use it myself on A2K applications.
Getting rid of "Like" did fix the problem.

But it then wouldn't be the same query.


That's fine with me. It was useful to find out that ADO may have a
problem with "Like", though that is the native Jet wildcard.

Thanks for the feedback, though it came with a dash of vinegar.

Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
1
by: John Sway | last post by:
I'm writing a web-based "Query analyser" tool for our company intranet. It allows a user to type any SQL statement in a form, and execute it over the Web. The SQL can be a query that returns...
11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
2
by: Michael C | last post by:
Hi all. When I run the following query against my Access database - from within Access - it returns the correct results (5 records in this instance): SELECT * FROM WHERE = "Clothes" AND LIKE...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
3
by: Bill Hutchison | last post by:
I have a query that returns different results (3508 rows for snapshot, 6288 for dynaset) and that is the only thing I change to get the different results. When I try to make a table from the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.