469,658 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Project with dataset, datatable, and datarow.

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.

Nov 17 '07 #1
2 1689
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.

"Mr. Arnold" wrote:
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.

Nov 19 '07 #2

"aiKeith" <ai*****@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
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.

Nov 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Yosh | last post: by
1 post views Thread by Fleckman | last post: by
2 posts views Thread by Mark Goldin | last post: by
3 posts views Thread by jcrouse | last post: by
12 posts views Thread by Brian | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.