Solved

Can't figure out cause of warning

Posted on 2011-03-15
2
327 Views
Last Modified: 2012-08-13
Hi, there.  I am getting this warning on the code that follows:

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

Private Sub LoadData()
    Dim ds As New DataSet
    Try
        ds = objEngine.SelectRecords("frmDataAssociates")

The underlined code is where the warning is.

Here's the objEngine.SelectRecords() code:

Public Shared Function SelectRecords(ByVal formName As String, Optional ByVal mTab As Integer = 0) As DataSet
        Dim mConnection As OleDbConnection = GetConnection()
        Dim mConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\CLRS\CLRS.mdb"
        Dim mDataSet As New DataSet
        Dim mAdapter As OleDbDataAdapter

        Dim str As String = ""
        Dim tableName As String = ""
        Dim b As New HeaderDB
        Dim objHeader As New Header
        Try
            objHeader = b.Load()
            Select Case formName
                Case "frmSetup"
                    Select Case mTab
                        Case 0, 4 ' Current Month and System
                            str = "SELECT CurrentMonthName,CurrentYear,LegacyCO,Region,RegionPresident,GeneralManager,Manager "
                            str &= "FROM Header;"
                            tableName = "Header"
                        Case 1 ' Stores
                            str = "SELECT StoreID,StoreAbbreviation,StoreState,StoreName "
                            str &= "FROM Stores "
                            str &= "ORDER BY StoreState,StoreName;"
                            tableName = "Stores"
                        Case 2 ' Associates
                            str = "SELECT AssociateID,StoreName,AssociateName "
                            str &= "FROM Associates "
                            str &= "ORDER BY StoreName,AssociateName;"
                            tableName = "Associates"
                        Case 3 ' Products
                            str = "SELECT ProductID,ProductName,ProductType "
                            str &= "FROM Products "
                            str &= "ORDER BY ProductType,ProductName;"
                            tableName = "Products"
                    End Select

                Case "frmDataStores"
                    str = "SELECT  RecordID, CurrMonthName, CurrYear, StoreName, ProductName, Target, Actual, PercentValue "
                    str &= "FROM DataStores "
                    str &= "WHERE (CurrMonthName = '" & objHeader.CurrentMonthName & "') "
                    str &= "AND (CurrYear = " & objHeader.CurrentYear & ") "
                    str &= "ORDER BY StoreName,ProductName;"
                    tableName = "DataStores"

                Case "frmDataAssociates"
                    str = "SELECT RecordID,CurrMonthName,CurrYear,StoreName,AssociateName,ProductName,Target,Actual,PercentValue "
                    str &= "FROM DataAssociates "
                    str &= "WHERE (CurrMonthName = '" & objHeader.CurrentMonthName & "') "
                    str &= "AND (CurrYear = " & objHeader.CurrentYear & ") "
                    str &= "ORDER BY StoreName,AssociateName,ProductName;"
                    tableName = "DataAssociates"

                Case "frmDataTraffic"
                    str = "SELECT TrafficID,CurrMonthName,CurrYear,StoreName,Traffic "
                    str &= "FROM DataTraffic "
                    str &= "WHERE (CurrMonthName = '" & objHeader.CurrentMonthName & "') "
                    str &= "AND (CurrYear = " & objHeader.CurrentYear & ") "
                    str &= "ORDER BY StoreName;"
                    tableName = "DataTraffic"

            End Select
            mConnection.Open()
            mDataSet = New DataSet
            mAdapter = New OleDbDataAdapter(str, mConnectionString)
            mAdapter.Fill(mDataSet, tableName)
        Catch ex As Exception
            ShowError(ex, "DBEngine.SelectRecords", Err.Number, str)
        Finally
            mConnection.Close()
        End Try
        Return mDataSet
    End Function

Open in new window


The code works without error, but I get the warning everytime objEngine.SelectRecords is called.  I hope this is enough information to help you figure out the problem.  Thanks so much.
0
Comment
Question by:Agent909
2 Comments
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35144267
Hi,

A shared method is not accessed via an object instance like a regular method, but rather is accessed directly from the class

Probably objEngine is an instance of a class, so, to avoid the warning, use the class to call your shared function.

Lets say that your class name is MyClass, then instead of instance the class you call the method directly like this

ds = MyClass.SelectRecords("frmDataAssociates")
0
 
LVL 1

Author Closing Comment

by:Agent909
ID: 35144294
That worked!  Thank you!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

14 Experts available now in Live!

Get 1:1 Help Now