Solved

Can't figure out cause of warning

Posted on 2011-03-15
2
335 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
[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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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