[.net] C#: Changes not appearing in MSSQL DB, after adding a row

Started by
1 comment, last by cyansoft 15 years, 2 months ago
Trying to add a new row to a "Customers" table; customerData is a strongly-typed DataSet which points to a local MSSQL database in my C# project.

customerData.CustomersRow custrow = customerData.Customers.NewCustomersRow();
custrow.CustomerID = 20;
custrow.CustomerName = "BrianCO";
customerData.Customers.Rows.Add(custrow);
customerData.AcceptChanges();
//llrpCustomerData.Customers.AcceptChanges();


The above code executes fine, but then when I close the program and look at the database which it connects to, the new row is nowhere to be seen... Any suggestions? I'm fairly new to using databases in C#, so it's entirely possible I'm just doin' it wrong... [Edited by - BTownTKD on April 22, 2009 2:44:18 PM]
Deep Blue Wave - Brian's Dev Blog.
Advertisement
Are you sure that the row is being inserted into the database?

My knowledge of this is rusty, I'll admit, but it looks to me like you might be adding your new row to the local DataSet which is then not committing to the actual underlying database.
Quote:customerData.AcceptChanges();

Replace the above line with a call to the Update method on your DataAdapter.


This topic is closed to new replies.

Advertisement