How to display data from dataadapters in a textbox

crystalelle

New member
Joined
Mar 4, 2008
Messages
4
Programming Experience
Beginner
Good day to all you good people out there. I need help again.

I have created a query using table adapter to sum up an amount in OrderDetail table. I now need to display the sum amount in a textbox from the OrderHeader table. I have no idea how I could do it.

What coding shall I use?

Please help.
 
I cant because the textbox I am using belongs to another table. Binding 2 tables in 1 textbox generates error. My situation is like this...

Well I have 2 tables.

Table Purchase Header = Total Value
Table Purchase Line = Unit Price, Qty

My tableadapter query for the Purchase Line goes like this

Select Sum([Purchase Line].Unit Price * [Purchase Line].Qty]) As Order Value
From [Purchase Line] Inner Join
[Purchase Header] On [Purchase Line].OrderID = [Purchase Header].OrderID
Group By [Purchase Line].OrderID

As you can see my query will return the total value for my order. I need to display this value to Total Value under Purchase Header Table then when user click save the Total Value will be save to Purchase Header.

Perhaps my idea in here is not too bright. You can suggest to me what other method that can be use. The key here is I need the summing of price*qty and save it to Total Value field
 
Word of advice: DONT USE SPACES in field names or table names! Instead of Purchase Line, call it PurchaseLine. Makes queries much easier and removes 99.9% of all issues regarding the syntex of creating queries.

Not sure if I understand what you have exactly, but I assume then you run that query to get the sum after you have loaded the purchase headers and lines ??

Also assume (as its an order) that the order lines will never change? I.E. someone makes an order, you sum it all up, and save that value to the purchase header TotalValue field.
What if someone wants to edit their order and remove a line from it? Unless you update that value explicitly after removing the line, the TotalValue will be wrong.


Personally I wouldn't even save this field (TotalValue) to the database. Just have it as an expression on the dataTable.
 
Perhaps my idea in here is not too bright.

You can say that again.. Pray tell me, when you run a joined, grouped, summed query, and then change a value and want to save it.. how will you save it?

Asked a simpler way:
SUppsoe you ran a query that summed the numbers in a column. Suppose that col contains the number 1,2,3,4 ,the sum is 10
You see 10 in your app
You edit it to 11

Now.. which row would you like the database to change so that the sum adds up to 11? Pick one at random? :)
 

Latest posts

Back
Top