Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Dataset - Get Values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 25 Sep 2007 02:29 GMT
Hello,
I have an SQL Stored Procedure that uses Inner Join to return the
records of various related tables:
SELECT * FROM dbo.by27_Blogger_Posts p
LEFT JOIN (
 SELECT *
 FROM dbo.by27_Blogger_Comments c
 LEFT JOIN dbo.by27_Membership_Users u
 ON c.AuthorId = u.UserId) AS cu
ON p.PostId = cu.PostId
...
WHEREp.PostId = @PostId
ORDER BY p.PostUpdatedDate

Now I get a dataset with all this data.
How can I, for example, loop through each PostId? And for each PostId
loop through each CommentId associated to it? And of course access the
columns?

The SQL code section I post applies to the 2 tables:
[Posts] > PostId, Title, ...
[Comments] > CommentId, PostId, Body, ...

Thanks,
Miguel
Chris Fulstow - 25 Sep 2007 04:18 GMT
Hi Miguel,

Maybe check out Scott Guthrie's ASP.NET data access tutorials, the
sections about Typed DataSets and TableAdapters might be useful to
you.

http://www.asp.net/learn/data-access/#advanced

Chris

> Hello,
> I have an SQL Stored Procedure that uses Inner Join to return the
[quoted text clipped - 21 lines]
> Thanks,
> Miguel
Peter Bromberg [C# MVP] - 25 Sep 2007 12:48 GMT
The SQL Statement you show will return a single resultset. So the DataSet you
get back from this will have a single DataTable with all the columns.
-- Peter
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com

> Hello,
> I have an SQL Stored Procedure that uses Inner Join to return the
[quoted text clipped - 21 lines]
> Thanks,
> Miguel
shapper - 25 Sep 2007 13:08 GMT
On Sep 25, 12:48 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.com> wrote:
> The SQL Statement you show will return a single resultset. So the DataSet you
> get back from this will have a single DataTable with all the columns.
[quoted text clipped - 29 lines]
> > Thanks,
> > Miguel

Peter,

I know but the question is:
Is it possible to create the loop I mentioned or should I use various
SELECTs to return various tables?

Thanks,
Miguel
sloan - 25 Sep 2007 14:17 GMT
I already responded to this yesterday.

My suggestion was to have 2 resultsets (2 select statements) coming back,
and process those.

I gave a link to a complete working example.

....

Do you have a weak (untyped) or strong (typed) dataset you're dealing with?

..

Check my blog (again) and find the 1.1 version of the example I gave you
"Custom Objects in 1.1" or something like that.
I have extra dataset code there.

> On Sep 25, 12:48 pm, Peter Bromberg [C# MVP]
> <pbromb...@yahoo.yohohhoandabottleofrum.com> wrote:
[quoted text clipped - 41 lines]
> Thanks,
> Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.