Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 21st, 2008, 02:59 PM
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Repeater Using Stored Procedure

I found a great tutorial on how to use the nested Repeater control to display hierarchical data using ASP.NET 2.0 and VB.NET at http://www.aspnettutorials.com/tutor...peater-vb.aspx. But it uses SELECT statements within the codefile, while I want to use stored procedures instead. So if someone could give me a basic example of how to modify its code using stored procedures instead, it would be greatly appreciated. I've included the code to reference that I've already created that uses stored procedures. Thanks.

CREATE PROCEDURE [dbo].[spElectionResults] AS


SELECT ContestID, ContestTitle
FROM tblElectionResults
WHERE (VoteFor <> '00')
GROUP BY ContestID, ContestTitle
HAVING (COUNT(ContestID) >= 1)
ORDER BY ContestTitle ASC, ContestID ASC


'Declare global variables
    Dim sqlConn As SqlConnection
    Dim strConnection As String
    Public dr As SqlDataReader

    'Declare the parameters for stored procedures
    Private cmd_electionresults As New SqlCommand()

    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)

        Dim ds As New DataSet

        'Assign connection string
        strConnection = System.Configuration.ConfigurationManager.AppSettings("strConn")
        sqlConn = New SqlConnection(strConnection)

        'Open DB connection

        'Declare variables
        Dim strContestID As String = Nothing, strContestTitle As String = Nothing

        'Declare stored procedure
        cmd_electionresults = New SqlCommand("spElectionResults", sqlConn)
        cmd_electionresults.CommandType = CommandType.StoredProcedure

        'Execute stored procedure and data reader
        dr = cmd_electionresults.ExecuteReader()

        While dr.Read()
            'Assign variables from DB table
            strContestID = dr("ContestID").ToString()
            strContestTitle = dr("ContestTitle").ToString()

            'Trim trailing whitespace from address variables
            strContestID = strContestID.Trim
            strContestTitle = strContestTitle.Trim

            'Test variables
            'Response.Write("strContestID: " & strContestID & "<br />")
            'Response.Write("strContestTitle: " & strContestTitle & "<br />")

            'Assign labels
            lblContestID.Text = strContestID
            lblContestTitle.Text = strContestTitle
        End While


        'Close DB connection

    End Sub

  #2 (permalink)  
Old July 21st, 2008, 06:49 PM
Friend of Wrox
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts

get rid of this line here:

'Execute stored procedure and data reader
        dr = cmd_electionresults.ExecuteReader()


'Execute stored procedure and data reader
        dr = cmd_electionresults.ExecuteReader()

Jason Hall

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
How to dispaly attributes of xml nested repeater.. vishnu108mishra XML 0 November 15th, 2007 07:38 AM
nested repeater ramonjor ASP.NET 2.0 Basics 0 July 31st, 2007 04:18 AM
FindControl in nested repeater chrisk_47 .NET Framework 2.0 0 February 6th, 2007 10:45 PM
nested repeater david_ste ASP.NET 2.0 Professional 0 August 24th, 2006 09:52 AM
Stored Procedure -- Nested queries pinkandthebrain SQL Server ASP 8 February 28th, 2004 07:55 PM

All times are GMT -4. The time now is 03:32 AM.

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