' Assumes that connection is a valid OleDbConnection object.' Use the DataAdapter to fill and update the DataSet.Dim adapter As OleDbDataAdapter = New OleDbDataAdapter( _ "SELECT CategoryID, CategoryName FROM Categories ORDER BY CategoryID", _ connection)adapter.InsertCommand = New OleDbCommand( _ "INSERT INTO Categories (CategoryName) Values(?)", connection)adapter.InsertCommand.CommandType = CommandType.Textadapter.InsertCommand.Parameters.A dd( _ "@CategoryName", OleDbType.Char, 15, "CategoryName")connection.Open() ' Fill the DataSet.Dim categories As DataSet = New DataSetadapter.Fill(categories, "Categories")' Add a new row.Dim newRow As DataRow = categories.Tables("Categories").NewRow()newRow("Ca tegoryName") = "New Category"categories.Tables("Categories").Rows.Add( newRow)' Include an event to fill in the Autonumber value.AddHandler adapter.RowUpdated, _ New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)' Update the DataSet.adapter.Update(categories, "Categories")connection.Close()' Event procedure for OnRowUpdatedPrivate Shared Sub OnRowUpdated( _ sender As Object, args As OleDbRowUpdatedEventArgs) ' Include a variable and a command to retrieve the identity value ' from the Access database. Dim newID As Integer = 0 Dim idCMD As OleDbCommand = New OleDbCommand( _ "SELECT @@IDENTITY", connection) If args.StatementType = StatementType.Insert ' Retrieve the identity value and store it in the CategoryID column. newID = CInt(idCMD.ExecuteScalar()) args.Row("CategoryID") = newID End IfEnd Sub