Jump to content

Updating MS Access from datagrid

- - - - -

  • Please log in to reply
No replies to this topic

#1
MastaKay

MastaKay

    Newbie

  • Members
  • Pip
  • 6 posts
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.
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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users