Hi guys.Im looking to update my database from my datagrid.
My previous code is like this, so Im hoping sumone will assist me in doing so.
Code:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
If IsNumeric(txtFirstName.Text) Then
MsgBox("Please type your name in letters", MsgBoxStyle.Critical, "KNS System-Error")
Exit Sub
End If
If IsNumeric(txtCity.Text) Then
MsgBox("Please type your City in letters", MsgBoxStyle.Critical, "KNS System-Error")
Exit Sub
End If
If Not IsNumeric(txtPostalCode.Text) Then
MsgBox("Please type your PostalCode in numbers", MsgBoxStyle.Critical, "KNS-System-Error")
Exit Sub
End If
If Not IsNumeric(txtCelnumber.Text) Then
MsgBox("Please type your Cellphonenumber in numbers", MsgBoxStyle.Critical, "KNS-System-Error")
Exit Sub
End If
da = New OleDbDataAdapter("Select * From Employees", cn)
cb = New OleDbCommandBuilder(da)
ds = New DataSet
ds.Clear()
da.Fill(ds, "Employees")
dt = New DataTable
dt = ds.Tables("Employees")
Dim dr() As DataRow
dr = dt.Select("EmpID = " & txtEmpID.Text & "")
dr(0).BeginEdit()
'dr(0)("Client_ID") = txtClientID.Text
dr(0)("EFirstName") = txtFirstName.Text
dr(0)("ESurname") = txtSurname.Text
dr(0)("EDepartment") = cboDept.SelectedItem
dr(0)("EPassword") = txtPassword.Text
dr(0)("EConfirmPassword") = txtConfirm.Text
dr(0)("EPhonenumber") = mtxtPhoneNumber.Text
dr(0)("ECelnumber") = txtCelnumber.Text
dr(0)("EAddress") = txtAddress.Text
dr(0)("ECity") = txtCity.Text
dr(0)("EPostalcode") = txtPostalCode.Text
dr(0).EndEdit()
da.Update(ds, "Employees")
MsgBox("Record Edited Successfully")
Disabling()
End Sub
Problem is that this I did with text boxes.What Im looking for is updating directly from the datagrid.Thanx in advance