Solved

ASP.NET - Cannot find table 0.

Posted on 2011-03-11
6
1,947 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
ID: 35107035
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
ID: 35107091
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
ID: 35107121
This may also happen if you are using wrong connection string, I mean, invalid or connection string pointing to some different database.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35107267
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
ID: 35107599
check condition like this

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

        End If
0
 

Author Closing Comment

by:jdana
ID: 35113695
The sproc was coming up empty.  That was it.  Thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

8 Experts available now in Live!

Get 1:1 Help Now