[HELP] Editing MS ACCESS directly from DataGridView in VB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [HELP] Editing MS ACCESS directly from DataGridView in VB

    I'm using ms access 2003 and visual basic 2005. In my DELETE button I manage to delete a row in ms access direct from datagridview using this code

    Code:
     Dim con As New OleDbConnection
        Dim dt As New DataTable
        Dim ds As New DataSet
        Dim da As New OleDbDataAdapter
         
        Private Sub Informations_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           
            Me.MembersTableAdapter.Fill(Me.DataSet4.members)
    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\LibraryDatabase.mdb"
    
            ds.Tables.Add(dt)
            da = New OleDbDataAdapter("Select * from members", con)
            da.Fill(dt)
    
            DataGridView2.DataSource = dt.DefaultView
            con.Close()
    
    
       Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            Dim dt As New DataTable
            Dim ds As New DataSet
            ds.Tables.Add(dt)
            Dim da As New OleDbDataAdapter
            Dim i As Integer
            i = DataGridView2.CurrentRow.Index
    
            con.Open()
    
            da = New OleDbDataAdapter("Select * from members", con)
            da.Fill(dt)
    
            dt.Rows(i).BeginEdit()
            dt.Rows(i).Delete()
            dt.Rows(i).EndEdit()
    
            Dim cb As New OleDbCommandBuilder(da)
            da.Update(dt)
    
            DataGridView2.DataSource = dt.DefaultView
    
            con.Close()
    
        End Sub
    Now my problem is how to convert this code to modify a cell in datagridview and update the ms access as well. I tried a lot of codes in the internet but none of them works. Any vb guru here? Help me please. Thanx in advance.

    #2
    u r using adodb...i think it is much easier to use adodc...

    Comment

    Working...
    X