Hi,
i am trying to update one database table base on another table. all rows are updating but first row is not updating.
where is my mistake any idea?
'=====
Private Sub update_invoice_entry()
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=SQG-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.SelectCommand.Connection
da_inv.UpdateCommand = New SqlCommand()
da_inv.UpdateCommand.Connection = conn
da_inv.UpdateCommand.CommandText = "UPDATE dbo.dt_finnance_value_adition SET bank_doc_ref_no=@bank_doc_ref_no WHERE fund_id = @fund_id"
With da_inv.UpdateCommand.Parameters
.Add("@fund_id", SqlDbType.Int, 0, "fund_id")
.Add("@bank_doc_ref_no", SqlDbType.NChar, 10, "bank_doc_ref_no")
End With
'update statement end
da_inv.Update(ds_inv, "inv_table")
End Sub
For Each dr As DataGridViewRow In Me.dg1.Rows
ds_inv.Tables("inv_table").DefaultView.RowFilter = "exp_inv_no LIKE '" & dr.Cells(0).Value & "'"
For Each dr2 As DataGridViewRow In Me.dg2.Rows
dr2.Cells(13).Value = Me.tb_bank_ref_no_p.Text
Next
bs1.Filter = "exp_inv_no not is null"
dg2.Focus()
bs1.RemoveFilter()
update_invoice_entry()
i am trying to update one database table base on another table. all rows are updating but first row is not updating.
where is my mistake any idea?
'=====
Private Sub update_invoice_entry()
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=SQG-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.SelectCommand.Connection
da_inv.UpdateCommand = New SqlCommand()
da_inv.UpdateCommand.Connection = conn
da_inv.UpdateCommand.CommandText = "UPDATE dbo.dt_finnance_value_adition SET bank_doc_ref_no=@bank_doc_ref_no WHERE fund_id = @fund_id"
With da_inv.UpdateCommand.Parameters
.Add("@fund_id", SqlDbType.Int, 0, "fund_id")
.Add("@bank_doc_ref_no", SqlDbType.NChar, 10, "bank_doc_ref_no")
End With
'update statement end
da_inv.Update(ds_inv, "inv_table")
End Sub
For Each dr As DataGridViewRow In Me.dg1.Rows
ds_inv.Tables("inv_table").DefaultView.RowFilter = "exp_inv_no LIKE '" & dr.Cells(0).Value & "'"
For Each dr2 As DataGridViewRow In Me.dg2.Rows
dr2.Cells(13).Value = Me.tb_bank_ref_no_p.Text
Next
bs1.Filter = "exp_inv_no not is null"
dg2.Focus()
bs1.RemoveFilter()
update_invoice_entry()