Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 24th, 2003, 01:22 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default working with data in DataSet

my dataset contains data from a bridge table. it has these rows:

eveID .............. spkName
1 ...................... Bob
1 ...................... Harry
1 ...................... Jim
2 ...................... Bob
2 ...................... Tim
3 ...................... Bruce
3 ...................... George

i want to rearrange the data so that the result will be:

eveID .............. spkName
1 ...................... Bob, Harry, Jim
2 ...................... Bob, Tim
3 ...................... Bruce, George

in classic asp, i would do:

Dim arrID(), strID, i
strID = ""
i = 0

rs.MoveFirst
Do While Not rs.EOF
If rs(0) <> strID Then
strID = rs(0)
Redim Preserve arrID(1,i)
arrID(1,i) = rs(0)
i=i+1
End If
arrID(0,i) = arrID(0,i) & ", " & rs(1)
rs.MoveNext
Loop

how is this done in asp.NET?

i am extremely frustrated. in classic asp it is so easy. dotNET is supposed to be easier, yet it is so much more difficult to work with the data. is there no functionality built in to these objects that will ease the process?
Reply With Quote
  #2 (permalink)  
Old August 25th, 2003, 01:15 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where exactly are you having problems with what you are doing? You'll need to use different objects and make a few syntax changes, but your logic should not need to change. Firstly there is no recordset object any more, you'll need a datareader to go thru the records. Here's what I came up with. I just plugged your code into VS.Net and changed the syntax where needed until I didn't get any design-time errors, I didn't actually execute it.
Code:
Dim arrID(1, -1) As String
Dim strID As Int64
Dim i As Integer = 0
Dim objDR As SqlClient.SqlDataReader
While objDR.Read
    If objDR.GetInt64(0) <> strID Then
        strID = objDR.GetInt64(0)
        ReDim Preserve arrID(1, i)
        arrID(1, i) = objDR.GetInt64(0).ToString
        i += 1
    End If
    arrID(0, i) = arrID(0, i) & ", " & objDR.GetString(1)
End While
Hopefully that will get you off to the right start. If you are using a data provider other than MSSQL than you'll need to adjust accordingly.

Peter
Reply With Quote
  #3 (permalink)  
Old August 26th, 2003, 01:17 AM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thx for responding. i have just fixed it.

gonna take a while to get used to the oop platform.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset relations not working like expected panda869 C# 0 March 2nd, 2008 12:04 PM
DataSet data busybee ASP.NET 1.0 and 1.1 Basics 0 April 3rd, 2006 05:55 AM
Data from dataset bubljo ADO.NET 3 October 26th, 2004 08:02 AM
DataSet & data melvik ADO.NET 6 April 28th, 2004 07:58 AM
Dataset Contains Data? ashley_y VB.NET 4 January 29th, 2004 02:58 PM



All times are GMT -4. The time now is 07:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.