Solved

ASP.NET - Cannot find table 0.

Posted on 2011-03-11
6
1,936 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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

13 Experts available now in Live!

Get 1:1 Help Now