Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dataset - Get Values

Reply
Thread Tools

Dataset - Get Values

 
 
shapper
Guest
Posts: n/a
 
      09-25-2007
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

 
Reply With Quote
 
 
 
 
Chris Fulstow
Guest
Posts: n/a
 
      09-25-2007
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

On Sep 25, 11:29 am, shapper <(E-Mail Removed)> wrote:
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      09-25-2007
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



"shapper" wrote:

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

 
Reply With Quote
 
shapper
Guest
Posts: n/a
 
      09-25-2007
On Sep 25, 12:48 pm, Peter Bromberg [C# MVP]
<(E-Mail Removed)> 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.
> -- Peter
> Recursion: see Recursion
> site: http://www.eggheadcafe.com
> unBlog: http://petesbloggerama.blogspot.com
> BlogMetaFinder: http://www.blogmetafinder.com
>
> "shapper" wrote:
> > 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


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

 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      09-25-2007
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.





"shapper" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On Sep 25, 12:48 pm, Peter Bromberg [C# MVP]
> <(E-Mail Removed)> 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.
>> -- Peter
>> Recursion: see Recursion
>> site: http://www.eggheadcafe.com
>> unBlog: http://petesbloggerama.blogspot.com
>> BlogMetaFinder: http://www.blogmetafinder.com
>>
>> "shapper" wrote:
>> > 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

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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT: to get dataset values which has datarelation. s703360@emirates.com Javascript 0 05-04-2006 03:46 PM
DataSet and dataSet JimO ASP .Net 2 03-08-2006 02:39 PM
Unable get Boolean and Numeric values from XLS into Dataset and Datagrid vighnesh ASP .Net 3 08-04-2005 02:16 PM
Unable get Boolean and Numeric values from XLS into Dataset and Datagrid vighnesh ASP .Net Datagrid Control 3 08-04-2005 02:16 PM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N ASP .Net 1 10-31-2003 02:39 AM



Advertisments