D
Daryll Shatz
How do I add a new record to a table and then extract the rowID number that
was auto assigned to the record (ie: do a @@Indentity in code)?
I tried using this code but setting a dataview with a Sort value causes the
wrong record to be retrieved in the last statement. Any suggestions
welcomed.
'Table Layout:
RowID as AutoAssigned Integer
Col1 as anything
Col2 as anything
'Define a dataview with a sort value off the dataset table
Dim dv as New DataView(DataSet11.Table,"","Col2",
DataViewRowState.CurrentRows)
'Code to add a new record to a DataSet Table
Dim dr As DataSet1.TableRow
dr = DataSet11.Table.NewTableRow
'Populate datarow
dr.col1 = value1
dr.col2 = value2
'Write new record
DataSet11.Table.AddTableRow(dr)
'Sync(DataSet And DB)
daTable.Update(DataSet11, "Table")
'Repopulate(DataSet)
DataSet11.Table.Clear()
daTable.Fill(DataSet11, "Table")
RowID = dvTable(dvTable.count - 1)("ID")
was auto assigned to the record (ie: do a @@Indentity in code)?
I tried using this code but setting a dataview with a Sort value causes the
wrong record to be retrieved in the last statement. Any suggestions
welcomed.
'Table Layout:
RowID as AutoAssigned Integer
Col1 as anything
Col2 as anything
'Define a dataview with a sort value off the dataset table
Dim dv as New DataView(DataSet11.Table,"","Col2",
DataViewRowState.CurrentRows)
'Code to add a new record to a DataSet Table
Dim dr As DataSet1.TableRow
dr = DataSet11.Table.NewTableRow
'Populate datarow
dr.col1 = value1
dr.col2 = value2
'Write new record
DataSet11.Table.AddTableRow(dr)
'Sync(DataSet And DB)
daTable.Update(DataSet11, "Table")
'Repopulate(DataSet)
DataSet11.Table.Clear()
daTable.Fill(DataSet11, "Table")
RowID = dvTable(dvTable.count - 1)("ID")