Solved

sql syntax error when communicating to an access database in vb.net

Posted on 2007-11-20
1
172 Views
Last Modified: 2013-11-26
Hi,

I have the following sql syntax that talks to an access database: -

rs.Open("Select NetDelCost, TaxCost, sum(TaxCost + NetDelCost) as 'DeliveryNetttotal' , Sum(NetDelCost) as 'DeliveryGrossTotal' from products WHERE Sold = true ", conn)

it keeps coming up: -

You tried to execute a query that does not include the specified expression 'NetDelCost' as part of an aggregate function.

When I run it in vb.net.

What am I doing wrong please.

Many Thanks
Lee
0
Comment
Question by:ljhodgett
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 20319149
You're asking for both NetDelCost and its sum?  That's not going to make sense.  In order to get any benefit out of the SUM() aggregation, you're going to have to group some records together.  You're asking for each individual NetDelCost and the sum of it on each record ... which is the same thing.

What are your raw data?  And what are you trying to find?  I'm sure one of us can help you achieve that.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

22 Experts available now in Live!

Get 1:1 Help Now