Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2005, 06:30 AM
Authorized User
 
Join Date: Jun 2004
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default IndexOutOfRangeException

 Hi there.
This works fine when I execute the sproc in Query Analyzer. But on the ASP.NET page it gives me an "IndexOutOfRangeException".
I am trying to figure out why. Thanks.
SqlConnection cnSearchDetails = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            SqlCommand cmdSearchDetails = new SqlCommand("GetProjectDetails", cnSearchDetails);
            cmdSearchDetails.CommandType = CommandType.StoredProcedure;
            cmdSearchDetails.Parameters.Add("@ProjectID", Int32.Parse(Request.QueryString["ProjectID"]));
            cnSearchDetails.Open();
            SqlDataReader drSearchDetails = cmdSearchDetails.ExecuteReader();

             drSearchDetails.Read();


                lblCluster.Text = drSearchDetails["ClusterName"].ToString();
                lblSubCluster.Text = drSearchDetails["SubClusterName"].ToString();
                lblArea.Text = drSearchDetails["AreaName"].ToString();
                lblGroup.Text = drSearchDetails["GroupName"].ToString();
                lblProjectNumber.Text = drSearchDetails["ProjectNumber"].ToString();
                lblTitle.Text = drSearchDetails["Title"].ToString();
                lblStartDate.Text = drSearchDetails["StartDate"].ToString();
                lblEndDate.Text = drSearchDetails["EndDate"].ToString();
                lblContinuation.Text = drSearchDetails["ContinuationNumber"].ToString();
                lblAbstract.Text = drSearchDetails["Abstract"].ToString();
                lblNotes.Text = drSearchDetails["Notes"].ToString();
                lblGrantee.Text = drSearchDetails["GranteeName"].ToString();
                lblSubject.Text = drSearchDetails["Subject"].ToString();
                lblCommunities.Text = drSearchDetails["CommunityName"].ToString();
                lblDirector.Text = drSearchDetails["Name"].ToString();


            drSearchDetails.Close();
            cnSearchDetails.Close();

 
Old February 7th, 2005, 08:14 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

There can be several reasons behind it. May be your DataReader object doesn't contain any data at all. You can set a break point & use Watch window to debug this problem.

If you can dend me the line no. then it will be a bit easier for me to help you.

Before that just make sureyou have added the proper login to the database & also gave the Execution permission on that Stored Proc.

Hope It Helps !!
Bhaskar Ghosh





Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IndexOutOfRangeException dhoward VB.NET 2002/2003 Basics 4 February 20th, 2008 04:29 PM
System.IndexOutOfRangeException Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 13 May 31st, 2007 06:15 PM
System.IndexOutOfRangeException: - Please Help!!! olud ASP.NET 1.0 and 1.1 Basics 1 January 30th, 2007 02:56 PM
IndexOutOfRangeException - Chp 13, Page 446 aleahy BOOK: Beginning ASP.NET 1.0 1 November 5th, 2003 08:40 AM





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