I populate a DataSet using the DataAdapter into a SQL CE database . Data is mapped to a DataGrid that is bound to a DataSet DataTable. I have an auto-increment identifier field (or in an SQLCE called PRIMARY KEY IDENTITY ) in my DataSource; accordingly, I also set the auto-increment identifier column in my DataTable .
/* when DataTable is first populated, start counting from Rows.Count */ /* if empty, starts with 1 */ dt.Column["id"].AutoIncrementSeed = dt.Rows.Count + 1;
The problem occurs when I clear my DataTable. I want the reset auto-increment counter to return to 1, but could not, I tried the following:
dt.Clear(); dt.Dispose(); ds.Clear(); ds.Dispose() da.Dispose() dt.Column["id"].AutoIncrementSeed = 1;
He just left with the counter turned off in front of Clear() . How can I reset auto-increment in a DataTable?
source share