mash alyy

mash alyy

  • NA
  • 12
  • 6.7k

Modify record in datagridview and update to access db

Jul 27 2012 4:29 AM
hi.

I want to modify the record in datagridview, after modifying when I press Modify button it should update to access 2007 database and should display the updated record back to datagridview control.

Db name: stpl
table name: Equipments

My code is:

Try
Mycn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & System.Environment.CurrentDirectory & "\STPL.accdb")
        Command = New OleDbCommand("SELECT * FROM Equipments", Mycn)
        Mycn.Open()
        Dim myDA As New OleDbDataAdapter
        myDA = New OleDbDataAdapter(Command)
        Dim myDataSet As DataSet
        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
        myDataSet = New DataSet()
        myDA.Fill(myDataSet, "Equipments")
        Mycn.Close()
        DataGridView1.DataSource = myDataSet.Tables("Equipments").DefaultView
        txtMan.Focus()
        Mycn = Nothing
        Catch ex As Exception
            MessageBox.Show("Could not Load the Record")
        Mycn.Close()
        End Try

But the code is doing nothing when I modify the data, no error and no updation to access db.
Plz help me out.

Answers (2)