update data from another table.

eashrak

Member
Joined
Jan 25, 2012
Messages
5
Programming Experience
1-3
I have a query table like below

Check box Buyer product qty
A A 1
√ B B 2
C C 2
√ d d 4


And another table is

Customer id Produect Qty Bank ref no.

A2 b 2
B2 b 4

I have a “bank ref id” text box and value is ” yy/98”

One the basis of selected row, bank ref should update on second table.



Customer id Produect Qty Bank ref no.

1 b 2 yy/98
1 b 4 yy/98

ANY IDEA
 
Take a look back at what you've posted as a question and ask yourself "How would someone who has no idea what I'm doing be able to discern what I'm trying to achieve, and how to help, from what I've written?"

Contributors here aren't mind readers - if you're running into a problem with your code, post the code and the error message.
 
Last edited:
use
VB.NET:
 tags
put commas between your column names and data entries when describing your tables so we can see where they start and end:

Check box Buyer product qty <--FIVE WORDS
 A A 1 <-- THREE WORDS
 √ B B 2 <-- FOUR WORDS

Confusing, what?
[code]
CheckBox,Buyer,Product,Qty
Y,A,A,1
 ,B,B,2

Better, no?

See.. we give free advice here; if we have to think too hard just to understand your post, we wont bother spending any thinking on your problem
 
use
VB.NET:
 tags
put commas between your column names and data entries when describing your tables so we can see where they start and end:

Check box Buyer product qty <--FIVE WORDS
 A A 1 <-- THREE WORDS
 √ B B 2 <-- FOUR WORDS

Confusing, what?
[code]
CheckBox,Buyer,Product,Qty
Y,A,A,1
 ,B,B,2

Better, no?

See.. we give free advice here; if we have to think too hard just to understand your post, we wont bother spending any thinking on your problem

sorry to make it complex,

here it is


+''''

I have a query table like below
Table-1
Check box, Buyer , product
, buyer-1, A
√, buyer-2, B
, buyer-3,C
√, buyer-4,d
And another table is
Table-2
Customer id, buyer, Qty, Bank ref no.
Customer-2, buyer-1, 40, blank
Customer-1, buyer-2, 20, blank
Customer-2, buyer-3, 40, blank
Customer-2, buyer-4, 30, blank

I have a “bank ref id” text box and value is ” yy/98”
One the basis of selected row, bank ref should update on second table.
Updated Second table should be
Customer id, buyer, Qty, Bank ref no.
Customer-1, buyer-2, 20, yy/98
Customer-2, buyer-4, 30, yy/98

++======
 
Try

UPDATE table-2 SET bank_ref_no = 'yy/98' WHERE EXISTS (SELECT 1 FROM table-1 WHERE checkbox = '√' AND table-1.buyer = table-2.buyer)
 
my code is


Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=asa-133;User Id=" & My.Forms.LoginForm.UsernameTextBox.Text & ";Password=" & My.Forms.LoginForm.PasswordTextBox.Text & ";Initial Catalog=" & My.Forms.LoginForm.tb_database.Text & "")

'update statement----
conn = da_inv_table.SelectCommand.Connection

da_inv_table.UpdateCommand = New SqlCommand()

da_inv_table.UpdateCommand.Connection = conn

da_inv_table.UpdateCommand.CommandText = "UPDATE dbo.dt_finnance_value_adition SET bank_doc_ref_no=@bank_doc_ref_no WHERE exp_inv_no = @exp_inv_no"

With da_inv_table.UpdateCommand.Parameters
.Add("@exp_inv_no", SqlDbType.NVarChar, 50, "exp_inv_no")
.Add("@bank_doc_ref_no", SqlDbType.NChar, 10, "bank_doc_ref_no")
End With

'update statement end
da_inv_table.Update(ds_inv, "inv_update")


+===

but i receive error message

Update requires a valid InsertCommand when passed DataRow collection with new rows.

any idea
 
Means youre adding new rows to the datatable ds_inv.inv_update, and da_inv_table needs to have a valid INSERT command so it can insert your new rows

Don't confuse da_inv_table.Update() with an SQL UPDATE command..

Calling Update(...) causes .net to loop through your table, carrying out an SQL INSERT, UPDATE or DELETE operations depending on the state of the row it is processing (inv_update.Rows(0).RowState: RowState.New => perform INSERT [uses da_inv_table.InsertCommand], RowState.Modified=>UPDATE [uses UpdateCommand], RowState.Deleted => DELETE [uses DeleteCommand])
 
Means youre adding new rows to the datatable ds_inv.inv_update, and da_inv_table needs to have a valid INSERT command so it can insert your new rows

Don't confuse da_inv_table.Update() with an SQL UPDATE command..

Calling Update(...) causes .net to loop through your table, carrying out an SQL INSERT, UPDATE or DELETE operations depending on the state of the row it is processing (inv_update.Rows(0).RowState: RowState.New => perform INSERT [uses da_inv_table.InsertCommand], RowState.Modified=>UPDATE [uses UpdateCommand], RowState.Deleted => DELETE [uses DeleteCommand])

i successfully update my table. with same update code. i use data filter to put value in specific row and i use same update command. now i have another problem. after using ds_inv.Tables("inv_table").DefaultView.RowFilter first row is not updating. i am using VS 2010.

any idea?
 
Your posts make nearly no sense. Add more words. Work out what
VB.NET:
 tags are. make my life easier; I'm helping you for free - you make my life hard, I don't bother
 
Back
Top