473,383 Members | 1,864 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,383 software developers and data experts.

ADO.NET questions

Hi All

I have a couple of questions, I am not at a machine with
VS.NETso that is why I am asking them here

1. When working with a dataset, how do I go to a specific
record and update a field in a table in the dataset? I
know you could probably run the updateCommand for the
DataAdapter, but that would update the data directly in
the database, and not in the dataset - not so? I want to
update a field in my datasets' datatable and then somehow
tell the dataset to update the database, how do I do this?

2. This one is about dataRelations. I have set up a
datarelation between two datatables in my dataset. Now I
have a for each loop that cycles through each record in
the one datatable, inside that for loop I want another for
each loop that will get me the child rows for the parents
ID column. my code looks something like this

for each (DataRow dr in dataset.tables["tablename"])
{

for each (DataRow childdr in dr.GetChildRows(Datarelation)
{
//do some work here
}

}

The inside for each, executes, but it is as if there are
no child rows for this parent column, .... but there is,
when I check the database. Is there something else that I
might be missing. I have setup the Datarelations
correctly, I have checked them sooo many times.

Any suggestions?

Thanks for any help it's greatly appreciated, If I have
not explained myself very well please let me know, I am
new to C#.
Thanks
Kevin

Nov 15 '05 #1
1 1067
See inline comments
"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
Hi All

I have a couple of questions, I am not at a machine with
VS.NETso that is why I am asking them here

1. When working with a dataset, how do I go to a specific
record and update a field in a table in the dataset? I
know you could probably run the updateCommand for the
DataAdapter, but that would update the data directly in
the database, and not in the dataset - not so? I want to
update a field in my datasets' datatable and then somehow
tell the dataset to update the database, how do I do this?
to update the individual rows you can access the rows and columns like this;
Dataset1.Tables["MyTableName"].Rows[nRowNumberToUpdate].["ColumnNameYouWantT
oUpdate"] = value;

As for updating the database you can either use stored procedures, which is
what I perfer. Or, you could create an update statement in SQL which will
probaly end up beeing more work in the end.
2. This one is about dataRelations. I have set up a
datarelation between two datatables in my dataset. Now I
have a for each loop that cycles through each record in
the one datatable, inside that for loop I want another for
each loop that will get me the child rows for the parents
ID column. my code looks something like this

for each (DataRow dr in dataset.tables["tablename"])
{

for each (DataRow childdr in dr.GetChildRows(Datarelation)
{
//do some work here
}

}

try this syntax;

for each (DataRow dr in dataset.tables["tablename"].ROWS)
{
DataRow[] childRows = dr.GetChildRows(DataRelation);
if(childRows.Length > 0)
{
for each (DataRow childdr in childRows)
{
//do some work here
}
}
}
The inside for each, executes, but it is as if there are
no child rows for this parent column, .... but there is,
when I check the database. Is there something else that I
might be missing. I have setup the Datarelations
correctly, I have checked them sooo many times.

Any suggestions?

Thanks for any help it's greatly appreciated, If I have
not explained myself very well please let me know, I am
new to C#.
Thanks
Kevin

Nov 15 '05 #2

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

Similar topics

0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
8
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying...
0
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
1
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
0
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
0
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions...
0
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.