Hi,
I have table in database with columns(ID int autoincrement primary key, Name nvarchar, Value nvarchar).
I have a form and on form load in code activity I have:
DataSet ds = dummyTableBo1.Read();
DataTable dt = ds.Tables[0];
DataRow dr = dt.NewRow();
dr[1] = "name1";
dr[2] = "value1";
dt.Rows.Add(dr);
dummyTableBo1.Write(ds);
code above add to datatable new row, this row is displayed on the form in the grid but is not added to database yet - and its ok for me because I only want to display data without saving.
now on form submit I have:
DataSet ds = dummyTableBo1.Read();
DataTable dt = ds.Tables[0];
dt.Rows.Clear();
dummyTableBo1.Write(ds);
code above should delete all rows from datatable and submit this changes to database, unfortunatelly it saves row which i added on form load.
I tried to delete this row using Delete method but i have access violation exception.
DataRow dr = dt.Rows[0];
dr.Delete();
Could someone tell me how is it possible and how to deal with it? I could just use DeleteDatabaseRows method but I want to avoid redundant database operations.