Home All Groups Group Topic Archive Search About

Result of a query into a variable in VB.NET

Author
29 May 2006 9:46 AM
Tom.Lismont
Hi there,

I'm currently working on a small project to create an overtime hour
app. I'm a little bit stuck on the part where I want to make the sum of

all the overtime hours entered in my db.
I'm working with an Access db. Users can enter the amount of overtime
hours performed on a single day. Every day is 1 record. What I want to
do now is make the sum of all the hours that were entered and pass it
into a variable. I can create the query with a SELECT SUM (...) but I
don't know how to pass the result back into a variable in VB. I need to
have it in a variable in VB because I need to do some calculations with
it.
Could somebody help me out with this one?

Author
29 May 2006 10:26 AM
Ken Tucker [MVP]
Hi,

Take a look at oledbcommand.executescalar
http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbcommand.executescalar.aspx

Ken
--------------------
<Tom.Lism***@gmail.com> wrote in message
Show quoteHide quote
news:1148895995.058873.178100@i40g2000cwc.googlegroups.com...
> Hi there,
>
> I'm currently working on a small project to create an overtime hour
> app. I'm a little bit stuck on the part where I want to make the sum of
>
> all the overtime hours entered in my db.
> I'm working with an Access db. Users can enter the amount of overtime
> hours performed on a single day. Every day is 1 record. What I want to
> do now is make the sum of all the hours that were entered and pass it
> into a variable. I can create the query with a SELECT SUM (...) but I
> don't know how to pass the result back into a variable in VB. I need to
> have it in a variable in VB because I need to do some calculations with
> it.
> Could somebody help me out with this one?
>
Author
29 May 2006 10:38 AM
Tom.Lismont
Thnx , This is what I was looking for.