473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1871
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 same datasource? I hope this makes sense. ...
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 changes. Here is the scenario: I add a row to a...
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 then just add rows as my Program runs. Is there...
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 DataSet("HCPViewer") dsH.Tables.Add(dt1)
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 DataSet, not IEnumerable. I don't know how to...
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 can't seem to find any method to create a...
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 is how I can efficiently match data from one...
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 this? Where can I find some info on how to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.