473,396 Members | 1,864 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,396 software developers and data experts.

ADO SQL statement coming back wrong

Someone please help. I have a peice of code (below) that when run from
VB returns a value of -2 but when I run the exact same SQL statement
from Access it produces the correct value of 7. Can anyone help?

Table: tblResp
Column 1: VarName (Char, 8)
Column 2: Resp (Char, 40)

VarName Resp
M5d "0"
M5h1 "-9"
CGF4a "0"
CGF4b "0"
CGF4c "0"
CGF4d "0"
CGF4e "0"
CGF4f "7"

SQL Code: Select Sum(CDBL(tblResp.Resp)) As Response From tblResp
Where Resp Not Like '-*'
Jul 17 '05 #1
4 4915
For some reason, when using ADO (with Access files, anywasy), the LIKE keyword
uses the %
character instead of the *.

"David" <dh*******@chestnut.org> wrote in message
news:83**************************@posting.google.c om...
Someone please help. I have a peice of code (below) that when run from
VB returns a value of -2 but when I run the exact same SQL statement
from Access it produces the correct value of 7. Can anyone help?

Table: tblResp
Column 1: VarName (Char, 8)
Column 2: Resp (Char, 40)

VarName Resp
M5d "0"
M5h1 "-9"
CGF4a "0"
CGF4b "0"
CGF4c "0"
CGF4d "0"
CGF4e "0"
CGF4f "7"

SQL Code: Select Sum(CDBL(tblResp.Resp)) As Response From tblResp
Where Resp Not Like '-*'

Jul 17 '05 #2
Are you executing the code against Access or against SQLServer? If
SQLServer, you need to use the CONVERT() TSQL function call. In
general, you cannot mix and match VB functions with SQL (unless you're
only doing Access databases...).

If you're doing VB stuff, will want to stick to ANSI SQL.

I hope this is helpful...
Jeramie

dh*******@chestnut.org (David) wrote in message news:<83**************************@posting.google. com>...
Someone please help. I have a peice of code (below) that when run from
VB returns a value of -2 but when I run the exact same SQL statement
from Access it produces the correct value of 7. Can anyone help?

Table: tblResp
Column 1: VarName (Char, 8)
Column 2: Resp (Char, 40)

VarName Resp
M5d "0"
M5h1 "-9"
CGF4a "0"
CGF4b "0"
CGF4c "0"
CGF4d "0"
CGF4e "0"
CGF4f "7"

SQL Code: Select Sum(CDBL(tblResp.Resp)) As Response From tblResp
Where Resp Not Like '-*'

Jul 17 '05 #3
Dear Steve Gerrard,

I was facing the same problem of 'LIKE *' in ADO sql string that david was facing. Thank you very much for your guidence. i worked very hard to solve this problem but no one was knowing. now u helped me. thnx. :) (people developed ADO/MS Access are careless, i should say. they dont know how hard the programmers work to make software, using ADO/Access. they should solve this problem.)

Are you executing the code against Access or against SQLServer? If
SQLServer, you need to use the CONVERT() TSQL function call. In
general, you cannot mix and match VB functions with SQL (unless you're
only doing Access databases...).

If you're doing VB stuff, will want to stick to ANSI SQL.

I hope this is helpful...
Jeramie

dhodgkins@chestnut.org (David) wrote in message news:<83b47ff1.0309291214.33a94db5@posting.google. com>...[color=blue]
> Someone please help. I have a peice of code (below) that when run from
> VB returns a value of -2 but when I run the exact same SQL statement
> from Access it produces the correct value of 7. Can anyone help?
>
> Table: tblResp
> Column 1: VarName (Char, 8)
> Column 2: Resp (Char, 40)
>
> VarName Resp
> M5d "0"
> M5h1 "-9"
> CGF4a "0"
> CGF4b "0"
> CGF4c "0"
> CGF4d "0"
> CGF4e "0"
> CGF4f "7"
>
> SQL Code: Select Sum(CDBL(tblResp.Resp)) As Response From tblResp
> Where Resp Not Like '-*'[/color]
Jun 12 '06 #4
Dear Steve Gerrard,

I was facing the same problem of 'LIKE *' in ADO sql string that david was facing. Thank you very much for your guidence. i worked very hard to solve this problem but no one was knowing. now u helped me. thnx. (people developed ADO/MS Access are careless, i should say. they dont know how hard the programmers work to make software, using ADO/Access. they should solve this problem.)

For some reason, when using ADO (with Access files, anywasy), the LIKE keyword
uses the %
character instead of the *.

"David" <dhodgkins@chestnut.org> wrote in message
news:83b47ff1.0309291214.33a94db5@posting.google.c om...[color=blue]
> Someone please help. I have a peice of code (below) that when run from
> VB returns a value of -2 but when I run the exact same SQL statement
> from Access it produces the correct value of 7. Can anyone help?
>
> Table: tblResp
> Column 1: VarName (Char, 8)
> Column 2: Resp (Char, 40)
>
> VarName Resp
> M5d "0"
> M5h1 "-9"
> CGF4a "0"
> CGF4b "0"
> CGF4c "0"
> CGF4d "0"
> CGF4e "0"
> CGF4f "7"
>
> SQL Code: Select Sum(CDBL(tblResp.Resp)) As Response From tblResp
> Where Resp Not Like '-*'[/color]
Jun 12 '06 #5

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

Similar topics

94
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
9
by: khan | last post by:
on sale report I want to make a check if customer doesnot pay full amount then his dues go in to his account recieveable table. I am trying this in vba and when I complie it on RunSQL it gives me...
12
by: Phoe6 | last post by:
The Program Fragment is this: int choice; /* Users Input Command */ .. .. .. printf("Enter a command: "); fflush(stdin); choice = getc(stdin); printf("\n");
5
by: Bill Priess | last post by:
Hey gang, Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope...
4
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" &...
0
by: Pancrazio Balsamo | last post by:
Hello, No. Love must suffer in this stern world; it ever had been so, it ever would be so. The remembrance of that life is fraught with so much pain to me, with so much mental suffering and...
3
by: emajka21 | last post by:
ASP 2.0/C# Access 2000 database I need to sum the top 3 race times. Below I can get the top 3 times but now how do I sum them? SELECT TOP 3 qryRaceTime.RaceTime FROM (Registered INNER JOIN...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.