How to delete all rows in a dataSet, Update problems

R

rdt

In ASP.net

Is there a way of deleting all the rows in a table in the dataset.

In regards to deleting all the rows is there a Delete/Remove function
similar to the simple update function of an DataAdapter
i.e objDataAdapter.Update(objDataSet, "TableName")?


In relation to updating is there anyway to update into a column with spaces
in its name using the simple update function - i.e objDataAdapter.Update
(objDataSet, "TableName")

Also is there a way finding out how many rows in a dataset?

Thanks
 
J

Jon Skeet [C# MVP]

rdt said:
In ASP.net

Is there a way of deleting all the rows in a table in the dataset.

In regards to deleting all the rows is there a Delete/Remove function
similar to the simple update function of an DataAdapter
i.e objDataAdapter.Update(objDataSet, "TableName")?

Use exactly the same thing, having deleted the rows from the tables -
and make sure your data adapter has a delete command.
In relation to updating is there anyway to update into a column with spaces
in its name using the simple update function - i.e objDataAdapter.Update
(objDataSet, "TableName")

Yup, just make sure the command has the table name in quotes or in
square brackets or whatever your database requires.
Also is there a way finding out how many rows in a dataset?

int total=0;
foreach (DataTable table in dataSet.Tables)
{
total += table.Rows.Count;
}

(Or something very similar - that's off the top of my head.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top