473,569 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6670
"shapper" <md*****@gmail. comwrote in message
news:11******** **************@ h2g2000hsg.goog legroups.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...@markNOSPA Mrae.netwrote:
"shapper" <mdmo...@gmail. comwrote in message

news:11******** **************@ h2g2000hsg.goog legroups.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.Article Id = (dataset("Artic leId")
Article.Title = (dataset("Artic leTitle")
...

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.ToStrin g( row("Title") )
a.Content = convert.ToStrin g( row("Content"))

' a.Comment.Comme ntID = 'left for you to do
' a.CommentTitle = 'left for you to do
' a.CommentCommen t = 'left for you to do
mycollection.Ad d(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.goog legroups.com...
On Apr 30, 11:53 am, "Mark Rae" <m...@markNOSPA Mrae.netwrote:
"shapper" <mdmo...@gmail. comwrote in message

news:11******** **************@ h2g2000hsg.goog legroups.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.Article Id = (dataset("Artic leId")
Article.Title = (dataset("Artic leTitle")
...

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
2994
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 example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
1
6062
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 (obviously, since it is a strongly typed DataSet). I used the drag & drop method to create the .xsd file. I have created 2 methods in my data...
5
2123
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 or something that completely abstracts you from the persistence details. Are you: 1. Having simple data type interfaces and the data layer know...
1
6837
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 itself (asp.net recycled?); it also can be solved by restarting IIS. Any ideas what cause(s) this to happen? System.Data.OleDb.OleDbException:...
3
1332
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 projects. We have used ADO datasets previously for a windows application that we developed where the entire db was loaded into the dataset at the...
10
2330
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 the DataAdd part (Section heading is Adding Rows to a DataSet) I dont really know what to do after i have added all the
6
2683
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 test-driven development, writing tests and then coding to satisfy them, I'll start with some of the simple tests for a class.
4
2467
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 PVS.myWS.Loader(); DataSet wsDS=load.WsLoad(); dataGrid1.DataSource=wsDS; string strConn = ConfigurationSettings.AppSettings;
4
16721
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 I: I found the ValueType field, leading me to believe that I could say dataGridView.Columns.ValueType = typeof(Double);...
3
2342
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 SqlCommandBuilder(dataAdapter); dataAdapter.Fill(dataSet, "POI_Entity"); DataRow dataRow = dataSet.Tables.NewRow(); dataRow = 1; dataRow =...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.