?
Solved

Can't figure out cause of warning

Posted on 2011-03-15
2
Medium Priority
?
336 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

741 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