Hi guys,
Looking for some help with this one.
I have an access database which is being read into a datagrid view. When I type directly into the datagridview and press "Save" it saves perfectly. But when I edit by passing the field values to another form to be edited and then pass them back to the datagrid view, they won't save at all. They look like they've been saved and can be seen in the DGV but when I restart the program they are gone.
As my save procedure works when I input directly into a DGV it must be how I'm passing the values back to the DGV that they are not saving. They don't seem to be "binding" to the DGV once passed back.
Here's how I pass them:
Any help would be greatly appreciated!
Looking for some help with this one.
I have an access database which is being read into a datagrid view. When I type directly into the datagridview and press "Save" it saves perfectly. But when I edit by passing the field values to another form to be edited and then pass them back to the datagrid view, they won't save at all. They look like they've been saved and can be seen in the DGV but when I restart the program they are gone.
As my save procedure works when I input directly into a DGV it must be how I'm passing the values back to the DGV that they are not saving. They don't seem to be "binding" to the DGV once passed back.
Here's how I pass them:
Code:
'Passing to the edit form
Dim indexPos As Integer = dgvStudents.CurrentCell.RowIndex
frmEdit.txtEditRecordID.Text = Me.dgvStudents.Item("StudentID", indexPos).Value
frmEdit.Show()
Me.Hide()
'Passing back from the edit form to the DGV:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Form3.SaveFromEdit()
Me.Close()
End Sub
Public Sub SaveFromEdit()
Dim indexPos As Integer = dgvStudents.CurrentCell.RowIndex
Me.dgvStudents.Item("student_IDNumber", indexPos).Value = frmEdit.txtEditStudentNumber.Text
Save()
End Sub
Public Sub Save()
Me.Validate()
Me.objStudentDA.Update(Me.objDataSet.Tables("tblStudent"))
Me.objDataSet.AcceptChanges()
End Sub