views:

4

answers:

1

Why is that? The state of the datarow is added. When I delete the row the state is unchanged. Why not deleted? Thats the reason my Delete Store Procedure is never called!

edit: the datarow is freshly added and then I try to delete it.

A: 

show your code please. my test shows that everything works fine:

        DataTable dt = new DataTable();
        DataRow dr = dt.NewRow();
        dt.Rows.Add(dr);
        Console.WriteLine(dr.RowState);
        dr.Delete();
        Console.WriteLine(dr.RowState);

output is:

        Added
        Detached
Andrey
why is it detached? should it be not deleted?
Lisa
@Lisa it is detached because previously it was added and state change was not accepted. if you first do `dt.ApplyChanges()` state will be Unchanged, if you delete it, it will be `Deleted`.
Andrey