Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27199

[VB2010] How to update a database Access??

$
0
0
Code:

Try

        'I open the connection
        Dim Path As String = DB_Folder & "\mydbase.mdb"
        Dim DBconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Path)

        DBconn.Open()

        Dim da As New OleDbDataAdapter("Select * From HH", DBconn)
        Dim ds As New DataSet
        Dim dt As New DataTable

        da.Fill(ds, "HH")
        dt = ds.Tables("HH")

        'I must declare or the Rows.Find method don't works
        dt.PrimaryKey = New DataColumn() {dt.Columns("Nome")}   

        Dim FoundRow As DataRow
        FoundRow = dt.Rows.Find(SearchName)
        If FoundRow Is Nothing Then MessageBox.......

        FoundRow.BeginEdit()
        FoundRow(2) = "John"
        FoundRow(4) = "Adam"
        FoundRow.EndEdit()

        'FoundRow.AcceptChanges() 'nothing changes if I take off
        'dt.AcceptChanges() 'nothing changes if I take off
        'ds.AcceptChanges() 'nothing changes if I take off

        Dim DBcommand As New OleDbCommandBuilder(da)
        da.Update(dt)
        'da.Update(dt, "HH") 'nothing changes
        'da.Update(ds)        'nothing changes
        'da.Update(ds, "HH") 'nothingchanges

        DBconn.Close()

Catch...........

Try... Catch don't gives exceptions.
If I stop the code and I control the dt content I can see that tha values are changed... but da.Update don't works...:confused:

What is wrong in the code??

Ty

Viewing all articles
Browse latest Browse all 27199

Trending Articles