Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Sum problem


Message #1 by "Paddy Anigbo" <dirosky@h...> on Thu, 14 Mar 2002 12:13:39 -0000
Hi,

I am getting an error with this sql string. Any ideas?

strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
strService & " AND Status=Booked OR Completed"

Error message:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Service=Somerset Road
(AND Status=Booked OR Completed)'.


Patrick
Message #2 by Thomas Bellavia <TBellavia@V...> on Thu, 14 Mar 2002 12:35:17 -0500
Do a 'Response.Write' of the SQL statement and make sure it looks correct...

-----Original Message-----
From: Paddy Anigbo [mailto:dirosky@h...] 
Sent: Thursday, March 14, 2002 7:14 AM
To: Access ASP
Subject: [access_asp] Sum problem

Hi,

I am getting an error with this sql string. Any ideas?

strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
strService & " AND Status=Booked OR Completed"

Error message:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Service=Somerset Road
(AND Status=Booked OR Completed)'.


Patrick

Message #3 by "Zee Computer Consulting" <zee@t...> on Thu, 14 Mar 2002 20:58:50 -0800
First, you need to put single quotes around strings when building your SQL
WHERE clause.

Second, assuming the Status field is also a string, you need to build a
valid compound WHERE clause. I suggest using a lot of parentheses to clearly
indicate each clause:

    strSQL = "Select Sum(Cost) as CTotal " _
                    & " FROM Bookings " _
                    & " WHERE (     ( Service = '" & strService & "' )"  _
                    & " AND (  ( Status = 'Booked' ) OR ( Status 
'Completed' )  )      )"


-- Zee




----- Original Message -----
From: "Paddy Anigbo" <dirosky@h...>
> I am getting an error with this sql string. Any ideas?
>
> strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
> strService & " AND Status=Booked OR Completed"
>
> Error message:
>
> Microsoft JET Database Engine (0x80040E14)
> Syntax error (missing operator) in query expression 'Service=Somerset Road
> (AND Status=Booked OR Completed)'.
>


Message #4 by "Thea Burger" <theab@l...> on Fri, 15 Mar 2002 09:08:57 +0200
Hi, Paddy

Try the query like this: 

strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
strService & " AND Status=Booked OR Status=Completed"

Hope this helps!!

Thea

-----Original Message-----
From: Paddy Anigbo [mailto:dirosky@h...] 
Sent: Thursday, March 14, 2002 7:14 AM
To: Access ASP
Subject: [access_asp] Sum problem

Hi,

I am getting an error with this sql string. Any ideas?

strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
strService & " AND Status=Booked OR Completed"

Error message:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Service=Somerset Road
(AND Status=Booked OR Completed)'.


Patrick

Message #5 by "Paddy Anigbo" <dirosky@h...> on Fri, 15 Mar 2002 10:05:26 -0000
Thanks Zee,

Overnight, I kinda figured out the errors of my ways. Exactly as you
described. Thanks.

Patrick
----- Original Message -----
From: "Zee Computer Consulting" <zee@t...>
To: "Access ASP" <access_asp@p...>
Sent: Friday, March 15, 2002 4:58 AM
Subject: [access_asp] Re: Sum problem


> First, you need to put single quotes around strings when building your SQL
> WHERE clause.
>
> Second, assuming the Status field is also a string, you need to build a
> valid compound WHERE clause. I suggest using a lot of parentheses to
clearly
> indicate each clause:
>
>     strSQL = "Select Sum(Cost) as CTotal " _
>                     & " FROM Bookings " _
>                     & " WHERE (     ( Service = '" & strService & "' )"  _
>                     & " AND (  ( Status = 'Booked' ) OR ( Status 
> 'Completed' )  )      )"
>
>
> -- Zee
>
>
>
>
> ----- Original Message -----
> From: "Paddy Anigbo" <dirosky@h...>
> > I am getting an error with this sql string. Any ideas?
> >
> > strSQL = "Select Sum(Cost) as CTotal FROM Bookings WHERE Service=" &
> > strService & " AND Status=Booked OR Completed"
> >
> > Error message:
> >
> > Microsoft JET Database Engine (0x80040E14)
> > Syntax error (missing operator) in query expression 'Service=Somerset
Road
> > (AND Status=Booked OR Completed)'.
> >
>
>
>
>

  Return to Index