Try to include
RS.Update()
on your loop:
For i As Integer = 0 To DGVRecord.RowCount - 1
RS("productname").Value = Me.DGVRecord.Rows(i).Cells("Product").Value
RS("batchno").Value = Me.DGVRecord.Rows(i).Cells("batchno").Value
RS("expirydate").Value = Me.DGVRecord.Rows(i).Cells("Expiry").Value
RS.Update()
Next
if doesn't work that code try the code below:
Public Const CONNECTION_STRING As String = "Data Source=YOUR_HOSTNAME;Initial Catalog=DATABASE_NAME; Integrated Security=True"
Dim dbConnection As SqlConnection = New SqlConnection(CONNECTION_STRING)
Dim ds As DataSet = New DataSet
Dim da As SqlDataAdapter
Private Sub updateDGV()
Dim SQLText As String = "SELECT Field1,Field2,Field3,Field4,Field5 FROM TEST"
Try
If dbConnection.State = ConnectionState.Open Then dbConnection.Close()
dbConnection.Open()
da= New SqlDataAdapter(SQLText, dbConnection)
da.Fill(ds, "TEST")
dbConnection.Close()
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
da.Update(ds, "TEST")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Call the updateDGV method to your Save button.
Hope this will help you.