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

[RESOLVED] Add new item to database and update immedeately

$
0
0
Hi,

I have the following code to add a new item to my database.
Code:

    Private Sub btnCommit_Click(sender As Object, e As EventArgs) Handles btnCommit.Click
        ' If inc <> -1 Then
        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsNewRow As DataRow

        dsNewRow = ds.Tables("AddressBook").NewRow()

        dsNewRow.Item("FirstName") = txtFirstName.Text
        dsNewRow.Item("Surname") = txtSurname.Text

        ds.Tables("AddressBook").Rows.Add(dsNewRow)

        da.Update(ds, "AddressBook")

        MsgBox("New Record added to the Database")

        btnCommit.Enabled = False
        btnAddNew.Enabled = True
        btnUpdate.Enabled = True
        btnDelete.Enabled = True

        '  End If
    End Sub

But i only can see this new item after i close and open again my form.
How can i see the item immedeately without the need to close?

Thanks!

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>