jt_murphree 24 Light Poster

I have a form with a table bound to a binding navigator. When I add a new record and commit it to the database I have to query the DB for the id of the record in order to to cave other records associated with the new one. The only way I have found to do this is to requery the database and fill the data table again. When I do this I need to point the binding back to the new record. Can anyone tell me how to do this or suggest a better way of doing it.

Dim label As String
        label = txtGrpLabel.Text
        Dim sInsert As String = "INSERT INTO tblProcGroup(ProcGroupLabel) VALUES('" & txtGrpLabel.Text & "')"

        Try
            Dim dbCommand As New OleDb.OleDbCommand(sInsert, con)
            dbCommand.ExecuteNonQuery()
            pGroups.Clear()
            Dim dataAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM tblProcGroup ORDER BY ProcGroupLabel", con)
            dataAdapter.Fill(pGroups)


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.