Autonumber Insert issues MS Access DB

Feb 4 2009 12:48 PM

frmNGXProgrammingRoot.theActiveUSID = dataAccessor.CloneAnUSSubMode (theUSID, whichSubMode, theNewName);

I have  a statement like this 

 

and the function dataAccessor.CloneAnUSSubMode  has the few lines of code as follows

DataRow rowUS = p_dataset.Tables["tblUltrasound"].NewRow();

//rowUS.SetParentRow(rowCase);

DataColumn idColumn;

foreach (DataColumn col in p_dataset.Tables["tblUltrasound"].Columns)

{

if (col.AutoIncrement)

{

// get column

idColumn = col;

// modify autoincrement seed and step (the real autoincrement values will be acquired after update from the db)

idColumn.AutoIncrementSeed = -999;

idColumn.AutoIncrementStep = -1;

continue;

}

rowUS[col]=rowUSDefault[col];

}

rowUS ["SubModeDescription"] = theNewName;

rowUS ["SubMode"] = newSubModeNumber

 

Basically I need to set the new row with some default values and modify few columns, and I need to writ ethe data to the DB only after collecting all the added/inserted data which is for couple more talbes.

Also I need to know the last ID inserted to the dataset actually to be inserted to the DB and establish the PArent child relationships tot he child table to set the data.

How am i to get the value of autonumber coulmn in MS access before insert/add and use it to the further down the link tables

Any help is appreciated.

thanks