Project with dataset, datatable, and datarow.

Project with dataset, datatable, and datarow.

am 17.11.2007 22:40:04 von 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.

RE: Project with dataset, datatable, and datarow.

am 19.11.2007 14:48:02 von aiKeith

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.
>
>

Re: Project with dataset, datatable, and datarow.

am 19.11.2007 23:39:52 von MR. Arnold

"aiKeith" wrote in message
news:5E2CF546-4F0F-4C0F-8425-F880FCB2C36D@microsoft.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.