1 Replies - 697 Views - Last Post: 27 July 2012 - 02:31 AM Rate Topic: -----

#1 mashalyy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-July 12

Modify the record in datagridview and update to access 2007 db

Posted 27 July 2012 - 01:30 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.
please help me out.

Mod edit
Use [code] tags when posting code.

:code:

This post has been edited by Atli: 27 July 2012 - 01:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Modify the record in datagridview and update to access 2007 db

#2 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 95
  • View blog
  • Posts: 882
  • Joined: 15-October 10

Re: Modify the record in datagridview and update to access 2007 db

Posted 27 July 2012 - 02:31 AM

That code above just gets records From the database. you need a update command to update records
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1