Solved

ASP.NET - Cannot find table 0.

Posted on 2011-03-11
6
1,923 Views
Last Modified: 2013-12-17
After I rebuild my database procedures on the production server, I'm getting the following error.

-------------------------------------------------------------------------------------------------------------
Cannot find table 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Cannot find table 0
--------------------------------------------------------------------------------------------------------------

I've attached the stack trace below.  I sure could use some advice in debugging / fixing this issue.
[IndexOutOfRangeException: Cannot find table 0.]
   System.Data.DataTableCollection.get_Item(Int32 index) +95
   ParkAsset.ParkAsset.DataAccess.GetFeatureValue(String ControlIdentity, String FeatureName) in C:\Users\jdana\Documents\DSD\Parks03\101218 - Production Web Interface\ParkAsset\App_Data\DataAccess.vb:288
   ParkAsset.ParkAsset.PagePrepper.DropDownListPrep(DropDownList ddl) in C:\Users\jdana\Documents\DSD\Parks03\101218 - Production Web Interface\ParkAsset\App_Data\PagePrepper.vb:104
   ParkAsset.ParkAsset.PagePrepper.PrepControls(Control ControlContainer, Int64 PrepType, Boolean Napalm, Int64 WorkOrderID) in C:\Users\jdana\Documents\DSD\Parks03\101218 - Production Web Interface\ParkAsset\App_Data\PagePrepper.vb:68
   ParkAsset.ParkAsset.PagePrepper.PrepControls(Control ControlContainer, Int64 PrepType, Boolean Napalm, Int64 WorkOrderID) in C:\Users\jdana\Documents\DSD\Parks03\101218 - Production Web Interface\ParkAsset\App_Data\PagePrepper.vb:87
   ParkAsset.WorkOrder.Page_Load(Object sender, EventArgs e) in C:\Users\jdana\Documents\DSD\Parks03\101218 - Production Web Interface\ParkAsset\workorder.aspx.vb:27
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Open in new window

0
Comment
Question by:jdana
  • 3
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
Comment Utility
This error will come when you try to fetch data when there is not data returned from database.

might be your procedure not returning any data

can you share our .net code where error comes?
0
 

Author Comment

by:jdana
Comment Utility
pratima_mcs,

Happy to.  I believe this is the problem code.  (DataAccess.vb:288) .  Here's the tricky part, my code loops on all the controls in the web page and uses the procedure WebRowSrcDrvFeatureValue to retrieve values associated with each control.  In other words, this procedure is called again and again during page load.  I'm not sure how to determine which control (ControlIdentity) and which feature (FeatureName) are giving the code trouble.

      Public Function GetFeatureValue(ByVal ControlIdentity As String, ByVal FeatureName As String) As String
         ' =============================================================================
         ' Purpose.: Return a Feature value based on an ASP control name and Feature name.
         ' Params..: ControlIdentity = The name (ID) of the control.  The value must match the 
         '           ControlIdentity found in WebRowSrcDrvFeatureValue.
         '           FeatureName = The name of the control Feature.  The value must match  
         '           the FeatureName found in WebRowSrcDrvFeatureValue.
         ' Returns.: The Feature value (as a string)
         ' =============================================================================

         Dim ds As DataSet
         Dim Parameters(1) As String

         Parameters(0) = ControlIdentity
         Parameters(1) = FeatureName
         ds = GetDataSetBasedOnSprocAndParams("WebRowSrcDrvFeatureValue", Parameters)
         If Not ds Is Nothing And ds.Tables(0).Rows.Count = 1 Then
            Return ds.Tables(0).Rows(0)(0).ToString()
         Else
            Return ""
         End If

      End Function

Open in new window

0
 
LVL 9

Expert Comment

by:gery128
Comment Utility
This may also happen if you are using wrong connection string, I mean, invalid or connection string pointing to some different database.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
debug after this statemen and check whether you are getting anything in ds table 0
may be you will get result in table 1

 ds = GetDataSetBasedOnSprocAndParams("WebRowSrcDrvFeatureValue", Parameters)


did you have two select statement in store procedure?
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 500 total points
Comment Utility
check condition like this

  If (ds.Tables(0) Is Nothing) Then

        End If
0
 

Author Closing Comment

by:jdana
Comment Utility
The sproc was coming up empty.  That was it.  Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now