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

Get data from dataset

Hello,

I have a stored procedures as follows:

SELECT a.ArticleID, a.Title, a.Content, c.CommentId, c.Title,
c.Comment
FROM Articles a
INNER JOIN Comments c ON a.ArticleID = c.CommentID
WHERE a.ArticleDate = @articledate

I get a dataset in my .NET code.

How can I get, from my dataset, given for example its ID, the title
and content of an article and all the titles and comments related with
that article?

Thanks,

Miguel

Apr 30 '07 #1
3 6665
"shapper" <md*****@gmail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
How can I get, from my dataset, given for example its ID, the title
and content of an article and all the titles and comments related with
that article?
http://www.google.co.uk/search?hl=en...Set+Find&meta=

--
http://www.markrae.net

Apr 30 '07 #2
On Apr 30, 11:53 am, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@h2g2000hsg.googlegro ups.com...
How can I get, from my dataset, given for example its ID, the title
and content of an article and all the titles and comments related with
that article?

http://www.google.co.uk/search?hl=en...B220GB220&q=Da...

--http://www.markrae.net
Hi,

A correction for my SQL Procedure:

SELECT a.ArticleID, a.Title, a.Content, c.CommentId, c.Title,
c.Comment
FROM Articles a
INNER JOIN Comments c ON a.ArticleID = c.ArticleID
WHERE a.ArticleDate = @articledate

Mark,

I know how to access a row of article:

Dim row As DataRow
For Each row In dataset.Tables(0).Rows

Article.ArticleId = (dataset("ArticleId")
Article.Title = (dataset("ArticleTitle")
...

Next row

My problem is how to access the comments for a given article in my
dataset.

I want to loop through each article and their comments and fell the
properties of two classes:

Article has the properties:

ArticleID, ArticleTitle, ArticleContent and Generic.List(Of Comment)

Comment has the properties:

CommentID, CommentTitle, CommentComment

I want to feel the class properties with the dataset values.

How can I do this?

Thanks,
Miguel

Apr 30 '07 #3


Huh? You gotta piggy back on the row.

Dim row As DataRow
For Each row In dataset.Tables(0).Rows
dim a as Article = new Article
a.ArticleId = Convert.ToInt32 ( row("ArticleID") )
a.Title = convert.ToString( row("Title") )
a.Content = convert.ToString( row("Content"))

' a.Comment.CommentID = 'left for you to do
' a.CommentTitle = 'left for you to do
' a.CommentComment = 'left for you to do
mycollection.Add(a) ' << you don't have this

>
Next row

If you have a strongly typed dataset, you need to probably cast the "row" as
the specific type of row you have
(Like if you have an Employee table in your dataset, you'd cast row as
'EmployeeRow")

If you need a full example of changing data into business objects ,
see

6/5/2006
Custom Objects and Tiered Development II // 2.0
http://sholliday.spaces.live.com/blog/
I use and IDataReader, but its the same concept.

"shapper" <md*****@gmail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
On Apr 30, 11:53 am, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@h2g2000hsg.googlegro ups.com...
How can I get, from my dataset, given for example its ID, the title
and content of an article and all the titles and comments related with
that article?
http://www.google.co.uk/search?hl=en...B220GB220&q=Da...

--http://www.markrae.net

Hi,

A correction for my SQL Procedure:

SELECT a.ArticleID, a.Title, a.Content, c.CommentId, c.Title,
c.Comment
FROM Articles a
INNER JOIN Comments c ON a.ArticleID = c.ArticleID
WHERE a.ArticleDate = @articledate

Mark,

I know how to access a row of article:

Dim row As DataRow
For Each row In dataset.Tables(0).Rows

Article.ArticleId = (dataset("ArticleId")
Article.Title = (dataset("ArticleTitle")
...

Next row

My problem is how to access the comments for a given article in my
dataset.

I want to loop through each article and their comments and fell the
properties of two classes:

Article has the properties:

ArticleID, ArticleTitle, ArticleContent and Generic.List(Of Comment)

Comment has the properties:

CommentID, CommentTitle, CommentComment

I want to feel the class properties with the dataset values.

How can I do this?

Thanks,
Miguel

Apr 30 '07 #4

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

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
1
by: Scott M. | last post by:
I have created a strongly typed dataset and populated it with data in my data layer. I have confirmed that the DataSet does, in fact contain my data and that there is a schema governing this data...
5
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
1
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
3
by: DwC | last post by:
Hi, We have a ms access database that we will be using to develop a website which would have fairly low usage levels. We have some experience with windows apps but not so much with asp.net...
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
4
by: JIM.H. | last post by:
Hello, I am trying to write the data I got from a web service to my table in SQL Server I need to append the dataset wsDS to the dataset ds and do update. PVS.myWS.Loader load = new...
4
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part...
3
by: Fred Chateau | last post by:
Any obvious reason here why data is not being loaded into the database? SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand); SqlCommandBuilder commandBuilder = new...
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:
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.