I have the following situation:
An ASP.NET Ajax web application uses a DataTable to write data to a database. The table is very simple, containing an autoincrement id.
My question:
If multiple users now use the web application, could it be that the same primary key id is given to multiple DataRows (leading to an error, when inserting the data into the database (duplicate key))? If I am right, the id is already generated, when calling .NewRow().
Thanks for your help!
An example:
----------------------------------------------------------
| ID (primary, autoincrement) | C1 | C2 |
----------------------------------------------------------
DataTable dt = new DataTable(name);
DataReader dr = ...;
dt.Load(dr); // => Now the data table has the rows from the database, including column definitions.
DataRow dr = dt.NewRow();
// => Now dr["ID"] is already set.