Solved

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

Posted on 2007-11-20
1
174 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now