Insert lines on an existing dataset

advertisements

I have a dataset called "titulos" and have 1 table there called "tb" with the columns with the name "titulo","titulo 2" and "titulo3". I'm trying to do an insertion of rows in the event onclick of a button but for some reason my code doesn't work! My dataset is on a xsd file and I am using visual studio 2013 with c#. I already tried this code but I don't know how to apply in my situation:

NorthwindDataSet.CustomersRow newCustomersRow =
northwindDataSet1.Customers.NewCustomersRow();
newCustomersRow.CustomerID = "ALFKI";
newCustomersRow.CompanyName = "Alfreds Futterkiste";
northwindDataSet1.Customers.Rows.Add(newCustomersRow);

The problem is that shows an error saying it does not recognize the dataset... The erros is : "The name " Ds_Admissibilidade" does not exist in the current context


A DataSet is a disconnected copy of the data. It forgets if the data originated from database, an xml file or anything else. When you add rows to the DataSet, you only change the in-memory copy, not the original source.

You need some mechanism to update the source. For databases, a table adapter or dataadapter will do this for you. For a file source, you need to serialize the DataSet to the file, much the reverse of the way you read in in first place.