locked
Reference to a non-shared member requires an object reference RRS feed

  • Question

  • I am getting the above error now when I run one of my ASPX pages, written in VB.NET. So I tried following the solution at: http://msdn.microsoft.com/en-us/library/zwwhc0d0(v=vs.80).aspx

    The above link seemed promising, cause it seemed to describe my problem exactly. However, I got the following error from this solution:

    System.ArgumentException: Column 'QXP_SHORT_DESC' does not belong to table Table

    Where the offending line is in this same main ASPX file:

    If pException("QXP_SHORT_DESC") = TheCategory Then

    But I know this stored proc does have an output field named this cause I can run this stored proc from query analyzer and I see it displayed.

    Here is my source code:

    Namespace 
    GlobalFunctions 
     Public Class GlobalF 
    Public Function ComplaintTrendingDrillDown3p(ByVal FirstMonth As DateTime, ByVal LastMonth As DateTime, ByVal rowLevel As Integer, ByVal productGroup As String, ByVal category As String, ByVal ListNumber As String) As DataSet 
    Dim DSPageData As New System.Data.DataSet 
    Dim param(5) As SqlClient.SqlParameter 
    param(0) = New SqlParameter("@FirstMonthDate", SqlDbType.DateTime) 
    param(0).Value = FirstMonth 
    param(1) = New SqlParameter("@LastMonthDate" 
    , SqlDbType.DateTime) 
    param(1).Value = LastMonth 
    param(2) = New SqlParameter("@TheLevel", SqlDbType.Int) 
    param(2).Value = rowLevel 
    param(3) = New SqlParameter("@ProductGroup", SqlDbType.Varchar) 
    param(3).Value = productGroup 
    param(4) = New SqlParameter("@TheCategory", SqlDbType.Varchar) 
    param(4).Value = category 
    param(5) = New SqlParameter("@ListNumber", SqlDbType.Varchar) 
    param(5).Value = ListNumber 
    ''# A Using block will ensure the .Dispose() method is called for these variables, even if an exception is thrown 
    ''# This is IMPORTANT - not disposing your connections properly can result in an unrespsonsive database 
    Using conn As New SQLConnection(ConfigurationSettings.AppSettings("AMDMetricsDevConnectionString")), _ 
    cmd 
    As New SQLCommand("ComplaintTrendingDrillDown3p", conn), _ 
    da As New SQLDataAdapter(cmd) 
    cmd.CommandType = CommandType.StoredProcedure 
    cmd.Parameters.AddRange(param) 
    da.Fill(DSPageData) 
    End Using 
    Return DSPageData 
    End Function 
    End Class 
    Public Class CallingClass 
    Public GlobalF2 As New GlobalF 
    'Public Function CallingClass(ByVal FirstMonth As DateTime, ByVal LastMonth As DateTime, ByVal rowLevel As Integer, ByVal productGroup As String, ByVal category As String, ByVal ListNumber As String) 
    ' Dim cc_new As New CallingClass() 
    'End Function 
    Public Function ComplaintTrendingDrillDown3p(ByVal FirstMonth As DateTime, ByVal LastMonth As DateTime, ByVal rowLevel As Integer, ByVal productGroup As String, ByVal category As String, ByVal ListNumber As String) As DataSet 
    Dim DSPageData As New System.Data.DataSet 
    Dim param(5) As SqlClient.SqlParameter 
    param(0) = New SqlParameter("@FirstMonthDate", SqlDbType.DateTime) 
    param(0).Value = FirstMonth 
    param(1) = New SqlParameter("@LastMonthDate", SqlDbType.DateTime) 
    param(1).Value = LastMonth 
    param(2) = New SqlParameter("@TheLevel", SqlDbType.Int) 
    param(2).Value = rowLevel 
    param(3) = New SqlParameter("@ProductGroup", SqlDbType.Varchar) 
    param(3).Value = productGroup 
    param(4) = New SqlParameter("@TheCategory", SqlDbType.Varchar) 
    param(4).Value = category 
    param(5) = New SqlParameter("@ListNumber", SqlDbType.Varchar) 
    param(5).Value = ListNumber 
    ''# A Using block will ensure the .Dispose() method is called for these variables, even if an exception is thrown 
    ''# This is IMPORTANT - not disposing your connections properly can result in an unrespsonsive database 
    Using conn As New SQLConnection(ConfigurationSettings.AppSettings("AMDMetricsDevConnectionString" 
    )), _ 
    cmd As New SQLCommand("ComplaintTrendingDrillDown3p" 
    , conn), _ 
    da As New SQLDataAdapter(cmd) 
    cmd.CommandType = CommandType.StoredProcedure 
    cmd.Parameters.AddRange(param) 
    da.Fill(DSPageData) 
    End Using 
    Return 
     DSPageData 
    End Function 
    End Class 
    End Namespace

    And from my main ASPX page calling this function:

    Dim gf As New GlobalFunctions.CallingClass 
     DSProductData = gf.GlobalF2.ComplaintTrendingDrillDown3p(FirstMonthDate, LastMonthDate, TheLevel, ProductGroup, TheCategory, ListNumber)
    I tried setting breakpoints, but it never breaked; it wouldn't compile due to this error.  And I tried printing columns of this table, but that didn't work also. 
    Ryan Daulton
    • Moved by Mike Feng Thursday, May 12, 2011 10:44 AM ASP .NET (From:Visual Basic Language)
    Tuesday, May 3, 2011 11:55 PM

Answers

All replies


  • On which line do you get the error?

    --
    Mike
    Wednesday, May 4, 2011 1:40 AM
  • Like it says above:

    If pException("QXP_SHORT_DESC") = TheCategory Then

    This line of code is in the main ASPX page that calls this function.

    And I'm pretty sure this datatable does have this column because I can see this column when I run it from Query Analyzer. 


    Ryan Daulton
    Wednesday, May 4, 2011 2:32 AM
  • Sorry, but your subject line really is confusing then, as it, and the posted code do not seem to have much of a relationship to the line where you are having an error occur.
     
    We, or better yet, the folks at http://forums.asp.net, would need to see the code around the line "if pException("QXP_SHORT_DESC") = TheCategory Then".  Also, the error message "...does not belong to table Table" would indicate to me that have a rather non-descript table name ("Table").  Is that really the table being used in your code?

    --
    Mike
    Thursday, May 5, 2011 12:39 AM
  • Hi Shaffiq,

     

    Welcome to the MSDN Forum.

     

    According to your description, it seems that it’s a ASP .NET issue, so you can consider posting ASP.NET forums for more efficient responses, where ASP.NET experts live in. Thanks.

     

    In addition, here are some tutorials:

    How to deploy an ASP.NET Web application using Xcopy deployment
    http://support.microsoft.com/kb/326355


    How to Deploy ASP.NET Web Application step-by-step (Including illustrations)
    http://www.beansoftware.com/ASP.NET-Tutorials/Deploy-ASP.NET.aspx 


    Video Lesson: Configuring, Building and Deploying a Web Site
    http://www.asp.net/learn/videos/video-05.aspx


    Get Started with ASP.NET
    http://www.asp.net/get-started/ 

     

    Best regards,
    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by ironryan77 Saturday, June 4, 2011 6:25 PM
    Thursday, May 5, 2011 2:03 PM