Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-20
1
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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