dataset - c# DataTable, deleting added row -
There is a problem with datasets in C #, which represents the structure and data of DB in the SDF file. I'm doing some automated testing with DB, so I should add some lines to the table, test and remove rows attached to the table.
My code is:
adapter.Fill (set); Line1 = data light. Add (empty, "name1", file.readlibets (@ "images \ photo1.jpg")); Line2 = dataable everyday. Add (empty, "name2", file.readlibets (@ "images \ photo2.jpg")); Adapter.Update (set); ... PERFORMING TEST ... ADAPTER. Fill (set); Row1.Delete (); Row2.Delete (); Adapter.Update (set); But the added rows are still in the base. I tried to use
figure Cry. Remove (line1); Datatable.Rows.Remove (line2); But this is the reason for the no-as-line-exception due to incorrect "number" values in line 1 and row 2, which is different from actual auto-integrated values in DB.
- How can I get the actual value of numbers when I am adding a line?
- Do "add rows" - & gt; "Do something" - & gt; "Delete rows" problem?
Thank you in advance. First of all, I have created a SQL query in DB, which adds a line.
And returns the new row's digit value:
INSERT [table] ([name], [photo]) value (@name, @photo); SELECT @@ IDENTITY I called it "InsertAndReturnIdentificator" and then I used to insert it directly into this adapter (with this new query) and delete the rows without using the dataset Private tap qualified & lt; Decimal & gt; ROW1; Private tap fit & lt; Decimal & gt; Line 2; Nullable as Row1 = adapter.Instore and ReturtIdentificator ("name1", file.readlibets (@ "images \ Photo1.jpg")) & lt; Decimal & gt ;; Line 2 = Adapters. Insert and Reuters Editititor ("Name 2", file. Redlibets (@ "Images \ Photo 2.JPG")) as faucetable and lieutenant; Decimal & gt ;; ... is performing ... adapter.Delete (decimal. ToInt32 (row1.Value)); Adapter.Delete (Decimal.ToInt32 (row2.Value));
Comments
Post a Comment