Project with dataset, datatable, and datarow.

M

Mr. Arnold

I am working a C# project that uses what's in the subject. I kind of have
the basics down on reading the table data. I don't use the above methods of
data access or persistence, but I am stuck with using this them in this
project.

I have selected rows based on selection criteria and the rows/records are
held in an ArrayList, so I can work with those rows/records, as the user
makes a selection to work with the data on the screen from a selected row.
I update column(s) on a row based on user input.

Now, I can just walk the ArrayList, select a row, select the columns, and
use an in-line SQL Update statement. But there has to be a better way. I
should be able populate the database table by using the existing rows in
the ArrayList, putting them in a Datatable and issuing some kind of Update
command with the DataTable.

If I can do this, how can it be done? I am so use to using data persist
objects, instead of dataset, datatable, and datarow.
 
G

Guest

Just out of curiosity, why are you putting the rows into an ArrayList to work
with the data?

You could just as easily perform a query on the row, get an array of
DataRows, modify the data and it would be reflected on the underlying table,
allowing you to perform the .Update()

ie:

DataRow[] dr = myDataSet.Tables[0].Select("pkVal=" + myVal);
dr["FirstName"] = "Changed to Pete";

myDataSet.AcceptChanges();

Now you can call the .Update() methods on your adapter.

Basically you can accomplish everything you need to do directly on the
DataSet/DataTable --

lemme know if this is clear or if can provide more assistance.
 
M

Mr. Arnold

aiKeith said:
Just out of curiosity, why are you putting the rows into an ArrayList to
work
with the data?

You could just as easily perform a query on the row, get an array of
DataRows, modify the data and it would be reflected on the underlying
table,
allowing you to perform the .Update()

ie:

DataRow[] dr = myDataSet.Tables[0].Select("pkVal=" + myVal);
dr["FirstName"] = "Changed to Pete";

myDataSet.AcceptChanges();

Now you can call the .Update() methods on your adapter.

Basically you can accomplish everything you need to do directly on the
DataSet/DataTable --

lemme know if this is clear or if can provide more assistance.

Thanks, I read this during lunch time and was able to goback to work and
sort this out quickly.
 

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