Is it possible to add rows to a dataset?
yes.
dim row as DataRow
row = ds.tables(0).NewRow
' Add Values to Row here
ds.tables(0).rows.add(row)
Yes, you can certainly add rows to the datatables in a dataset.
Check this MSDN page for a how-to. It covers both strongly typed datasets and untyped datasets.
To add a new record to a typed dataset
Declare a new instance of the typed dataset. In the following example, you declare a new instance of the CustomersRow class, assign it a new row, populate the columns with data, and add the new row to the Customers table's Rows collection:
Dim newCustomersRow As NorthwindDataSet.CustomersRow newCustomersRow = NorthwindDataSet1.Customers.NewCustomersRow() newCustomersRow.CustomerID = "ALFKI" newCustomersRow.CompanyName = "Alfreds Futterkiste" NorthwindDataSet1.Customers.Rows.Add(newCustomersRow)
To add a record to an untyped dataset
Call the NewRow method of a DataTable to create a new, empty row. This new row inherits its column structure from the data table's DataColumnCollection. The following code creates a new row, populates it with data, and adds it to the table's Rows collection.
Dim newCustomersRow As DataRow = DataSet1.Tables("Customers").NewRow() newCustomersRow("CustomerID") = "ALFKI" newCustomersRow("CompanyName") = "Alfreds Futterkiste" DataSet1.Tables("Customers").Rows.Add(newCustomersRow)
No. But I suspect you mis-worded your question.
You can add rows to a dataTABLE. A Dataset is made up of DataTables (or is empty).
In order to add rows to a DataTable, you first make the DataRow and then .Add it to the DataTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With