database loop

G

Guest

How can I total all records in a lineitem table that are equal to invoice
number 100 in a master detail relationship?
In Delphi it would be
Table1.first;
While not Table1.EOF
do begin
.....
Table1.next;
Can't figure out how in C# CF 2.0
Thanks Jon Stroh
 
P

Peter Morris [Droopy eyes software]

Why wouldn't you use Select count(*) from Blah where A = '1000' ?
 
C

chris-s

My understanding would be that doing a count(*) would be less
efficient, either use count(A) if 'A' is an indexed column or better
still "Select count (1) from blah where A = '1000'"

I've no evidence to support this, just gut instinct !

Chris
 
G

Guest

I already had set up a query set up but I didn't know how to get the result
in code.
Here is what I had:

SELECT SUM(Amount) AS EXPR1
FROM LineItem
WHERE (InvNum = @number)

Here is what I tried in my code to run it but I obviously don't understand
what it needs. I get the error no overload method CalcItems takes two
arguments. ??

This is what it asks for before I type after the (
decimal?CalcItems(int,Number)
float amt = 0;

this.lineItemTableAdapter.CalcItems(fB7MobileDBDataSet.LineItem.InvoiceInvNumColumn, amt);

I thought I was giving it the InvoiceNum column for the @number parameter
and the amt var to hold the result.

Thanks Jon Stroh
hope you can straighten me out. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top