Question Updating problem in access table

mounir_az

Member
Joined
Jan 11, 2009
Messages
18
Programming Experience
1-3
When I try to update the amount of stock for the products in the table "product" from a DataGridView that contains the name of the products, it update only the first record it finds the DataGridView, others not

this is my code:

Dim a, b As Integer
Dim row As DataGridViewRow

For Each row In ConsultationDataGridView.Rows

If con.State = ConnectionState.Open Then con.Close()
con.Open()

Dim dr As OleDbDataReader
Dim cmd As New OleDbCommand("select * from t_produit where [Designation_recharge] = '" & ConsultationDataGridView.CurrentRow.Cells(1).Value & "'", con)
'On Error Resume Next
dr = cmd.ExecuteReader
If dr.Read = True Then
a = dr(4)
End If

b = (Val(a) - Val(ConsultationDataGridView.CurrentRow.Cells(2).Value))
Me.T_produitTableAdapter.modprod(b,ConsultationDataGridView.CurrentRow.Cells(1).Value)

Next

How can I update all the product at the same time
 
You're doing your data access all wrong. please follow the Microsoft tutorials you will find in the DW2 link in my signature. Start by reading the Creating a Simple Data App one
 
Back
Top