none
Random errors "Cannot find table 0", "Column 'colName' does not belong to table Table" in ASP.NET RRS feed

  • Question

  • Environment Detail:

    Visual Studio 2008 SP2

    SQL Server Management Studio  2008 R2

    .Net Framework 3.5

    But my .Net Framework in Application Pools in IIS is v2.0


    My code as below:

    Dim ds As New DataSet
    ds = model.GetAnnouncement()
    
    If Not ds Is Nothing AndAlso ds.Tables.Count > 0 AndAlso ds.Tables(0).Rows.Count > 0 Then
       For i = 0 To ds.Tables(0).Rows.Count - 1
          lblTitle.Text = ds.Tables(0).Rows(i)("Title")
       Next
    End If

    And I call the store proc by following code:

    Public Function GetAnnouncement() As DataSet
       Try
          ds = New DataSet
          sQuery = "GetAnnouncement"
    
          Common.OpenConnection(Common.ConType.eGenericFundCon)
          ds = Common.ExecuteDataSet(sQuery, CommandType.StoredProcedure)
               
          Return ds
       Catch ex As Exception
          Throw ex
       Finally
           Common.CloseConnection()
       End Try
    End Function

    My store proc:

    CREATE PROCEDURE [dbo].[GetAnnouncement]
    
    AS
    BEGIN
         SET NOCOUNT ON
    	
         SELECT Top 1 PkID, Title, Description, Display Date, UpdatedDate, UpdatedBy
         FROM tblAnnouncement
         ORDER BY CreatedAt DESC
        
         SET NOCOUNT OFF
    END  
    I getting this error since few months ago, sometime after refresh the page that is no problem already. I keep change the code, but until now still unable to solve the error. Anyone can help? Thanks

     



    • Edited by howard hee Thursday, August 7, 2014 3:57 AM
    Thursday, August 7, 2014 3:56 AM

All replies

  • It could be that the connection pool for your application is being corrupted. Make certain that all of your connection objects are being properly released back to the connection pool by calling the Close method. Also, you may want to recycle the application pool for the app in IIS if it happens frequently.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, August 7, 2014 1:26 PM
  • I use code below to close the connection Is that any error?

        Public Shared Sub CloseConnection()
            If (dbConnection.State = ConnectionState.Open) Then
                dbConnection.Close()
                dbCommand.Parameters.Clear()
                dbCommand.Dispose()
            End If
        End Sub
    is that any approach to recycle the application pool automatic? Because I have to recycle the pool few times per day.  

    Friday, August 8, 2014 2:12 AM
  • That code looks OK. Can you identify the line of code where the exception occurs? It might help narrow down the problem.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Monday, August 11, 2014 7:19 PM
  • Hi Paul,

    The error is random occur when deployed into server. Not only this page, other page using method below also random occur:

    ds.Table(0).Row(0)('any column')

     I use my visual studio 2008 point to server and debug, no error at all.

    Tuesday, February 10, 2015 3:20 AM