472,348 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

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 1793
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yosh | last post by:
Let's say I have a DataRow that I got from DataSet "A". Can I modify the data in the DataRow and add it to a new DataSet "B" and have it update the...
1
by: Fleckman | last post by:
I have a situation where I need to add rows to tables with a Parent-Child relationship which presents a constraints violation when I reject the...
4
by: Wes | last post by:
I want to use a DataGrid and manually populate the data in the table. Does anyone know how this is done?? I want to create all the Columns, and...
2
by: Mark Goldin | last post by:
I pulling a dataset into my web form with one row of data. How do I extarct the values from that dataset? Thanks
3
by: jcrouse | last post by:
I have the following code that creates a couple of XML files: Dim dt1 As New DataTable("P1JoyUp") If H = True Then Dim dsH As New...
6
by: Nick | last post by:
I have a code that returns data in IList. My webGrid doesn't allow me to sort with IList returned, it say it only suports DataView, DataTable and...
10
by: AG | last post by:
I am trying to use a ReportViewer control in a VS 2005 web application project (not Website project). When I try to create a new report (local), I...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question...
12
by: Brian | last post by:
I want to create an In Memory dataset. not connected to any database.. but putting my own info in from code or a file.... What are the steps to do...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.