473,396 Members | 2,029 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,396 software developers and data experts.

Finding the index of the DataRow to update?

I've got a strongly-typed dataset with 2 related tables in it ("Staff"
and "Roles"). I want to make a change to the parent Staff row and also
to its child Role row. I'm having difficulty figuring out the best way
to do this.

First question:
I can get myself a new instance of a row and make changes to it, but
presumably that's then a separate object from the original dataset
row. How do I reconcile my changes back to the dataset?

Second question:
Because I haven't figured out the answer to the above, I'm updating
the rows directly in the dataset. But in order to find which row to
update, I'm having to do something which looks really complicated (see
code snippet below).

It can't be that difficult! But the MSDN examples are no help at all -
they simply refer to the required row using an absolute value:
dataset1.Tables["Customers"].Rows[4]["CompanyName"] = "Wingtip Toys";
How much use is that in The Real World?! Not much - what I need to
know is, how to dynamically find that value 4 in the example.

Any help would be much appreciated. Thanks very much. Here's the code
snippet:

//find the index of the Staff row to update (where StaffID=_staffID):
UserDataSet.StaffRow[] staffRows=this.GetStaffRowsxMany();
int i=0, rowID=0;
foreach(UserDataSet.StaffRow dr in staffRows)
{
if(dr.StaffID==_staffID)
rowID=i;
i++;
}

//update the staff datarow with the new values:
_dsUserData.Staff[rowID].Firstname=<some value>;

etc. then I do the same for the child table (Role) rows:

//find the index of the child Role row to update (where
StaffID=_staffID)
i=0;
int roleRowID=0;
foreach(UserDataSet.RolesRow rr in
_dsUserData.Staff[rowID].GetRolesRows())
{
if(rr.StaffID==_staffID)
roleRowID=i;
i++;
}

//update the Role datarow with the new values:
_dsUserData.Roles[roleRowID].GroupID=<some value>

etc ...
Nov 18 '05 #1
0 1378

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CJ Smit | last post by:
Hi Guys I have a datagrid that are databound at runtime and columns are added automatically to it from the dataset. OnEdit Command renders all fields as editable, my problem is I need to specify...
4
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out...
6
by: BB | last post by:
Hello all, I am using the currency manager in VB to navigate a dataset. I know how to use .position to loop through the rows, but what I want to do is *get* the position of the row I just...
11
by: Tim Frawley | last post by:
I need to return a DataRow or the Row Index in a DataSet wherein the value I am attempting to find is not a primary key. I have to do this often, more than 200 times when importing a file so it...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
2
by: JohnR | last post by:
Sorry if this is has an obvious answer, but I can't find it... I am using a datatable.select to obtain the rows in a datatable that meet certain criteria. My question is this: for each of the...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
0
by: dalaeth | last post by:
I have searched Google high and low and haven't found anything that works. Here's my problem, hopefully someone will be able to help! I'm using 1.1 Framework, and ODP.NET 9.5.0.7 on a Windows...
8
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.