i have a problem with saving data to access database this is my code
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Personnel").NewRow()
dsNewRow.Item("PerID") = txtPersonnelID.Text
dsNewRow.Item("FirstName") = txtFirstName.Text
dsNewRow.Item("Lastname") = txtLastName.Text
dsNewRow.Item("Middlename") = txtMiddleName.Text
dsNewRow.Item("Gender") = txtGender.Text
dsNewRow.Item("Address") = txtAddress.Text
dsNewRow.Item("ContactNo") = txtContactNo.Text
dsNewRow.Item("EmailAddress") = txtEmailAdd.Text
dsNewRow.Item("BDay") = txtBday.Text
dsNewRow.Item("Department") = txtDept.Text
dsNewRow.Item("HiredDate") = txtHiredDate.Text
dsNewRow.Item("RenewalDate") = txtRenewalDate.Text
ds.Tables("Personnel").Rows.Add(dsNewRow)
da.Update(ds, "Personnel")
MsgBox("New Record added to the Database")
btnSave.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
End If
End Sub
and when i save there's always Systems.Windows on the personnel id textbox? what seems to be the problem with my coding?
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
btnSave.Enabled = True
btnAddNew.Enabled = False
btnUpdate.Enabled = True
btnDelete.Enabled = False
txtPersonnelID.Clear()
txtFirstName.Clear()
txtLastName.Clear()
txtMiddleName.Clear()
txtGender.Clear()
txtAddress.Clear()
txtContactNo.Clear()
txtEmailAdd.Clear()
txtBday.Clear()
txtDept.Clear()
txtPosition.Clear()
txtHiredDate.Clear()
txtRenewalDate.Clear()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Personnel").Rows(inc).Item(0) = txtPersonnelID
ds.Tables("Personnel").Rows(inc).Item(1) = txtFirstName.Text
ds.Tables("Personnel").Rows(inc).Item(2) = txtLastName.Text
ds.Tables("Personnel").Rows(inc).Item(3) = txtMiddleName.Text
ds.Tables("Personnel").Rows(inc).Item(4) = txtGender.Text
ds.Tables("Personnel").Rows(inc).Item(5) = txtAddress.Text
ds.Tables("Personnel").Rows(inc).Item(6) = txtContactNo.Text
ds.Tables("Personnel").Rows(inc).Item(7) = txtEmailAdd.Text
ds.Tables("Personnel").Rows(inc).Item(8) = txtBday.Text
ds.Tables("Personnel").Rows(inc).Item(9) = txtDept.Text
ds.Tables("Personnel").Rows(inc).Item(10) = txtPosition.Text
ds.Tables("Personnel").Rows(inc).Item(11) = txtHiredDate.Text
ds.Tables("Personnel").Rows(inc).Item(12) = txtRenewalDate.Text
da.Update(ds, "Personnel")
MsgBox("Data updated")
End Sub
here's the screenshot of my program http://i43.photobucket.com/albums/e355/bettybarnes/screenshot.jpg