[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

ASP.NET - Cannot find table 0.

Posted on 2011-03-11
6
Medium Priority
?
2,068 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

656 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