Problem with dataset autoincrement column
I have a Datatable containing autoincrement column.
The code I have written for this is
DataSet BillDetails = new DataSet();
DataTable dt = new DataTable("Table");
DataColumn dc = new DataColumn("bill_line_no", typeof(Int32));
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 1;
dt.Columns.Add(dc);
BillDetails.Tables.Add(dt);
if (mode.Equals(Constants.ADD))
{
OracleHelper.FillSchema(BillDetails,OracleHelper.W ASPORT_WAS,
CommandType.StoredProcedure, get_bill_details, parms);
}
else
{
OracleHelper.ExecuteDataset(BillDetails,OracleHelp er.WASPORT_WAS,
CommandType.StoredProcedure, get_bill_details, parms);
}
This is working fine in the add mode where I am using the fill schema method to fill the dataset. It is working fine even in the case of edit mode where I am using Fill method of dataset.
I am getting the problem only when a record is deleted from the datatable and then a new record is inserted into it. The sequence generated is very strange.
For every new record being added, I am getting a sequence number which is equal to the number of records in the datatable when the first time it is loaded plus the number of records currently existing in the database + 1.
Can anyone help me in this regard?
|