472,364 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 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

//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)

//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
int roleRowID=0;
foreach(UserDataSet.RolesRow rr in

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

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

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

Similar topics

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...
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...
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...
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...
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...
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...
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...
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 on a Windows...
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...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
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 file that would suck all files in the folder and...
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 technical details, Gmail likely implements measures...
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 synthesis of my design into a bitstream, not the C++...
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. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.