Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scoping of class property
Message
From
19/12/2005 12:39:14
 
 
To
19/12/2005 11:05:15
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01079106
Message ID:
01079238
Views:
30
>Just a guess, based on your other recent posts ... you probably have oDataSet defined as a shared (static) member. This is not going to work this way, as you found out. Since shared members don't require an instance of the class, they are always the same every time they are referenced, since you reference them through the class, not through an instance of the class. You need to remove the shared keyword.

If I remove the Shared in the property definition, I cannot access this property from within a method of the class. Here is the code I have for it, the upper part:
Public Class Data

    Public oDataAdapter As OleDbDataAdapter
    Public Shared oDataSet As DataSet
    Public Shared oDataView As DataView
    Public Shared cSQL As String
    Public Shared cConnectionString As String
    Public Shared oConnection As OleDbConnection
    Public Shared nCount As Integer

    ' SQL exec
    ' expC1 SQL command
    ' expO1 Connection
    Public Shared Function SQLExec(ByVal tcSQL As String, ByVal toConnection As OleDbConnection) As Boolean
        Dim llSuccess As Boolean
        llSuccess = False
        cSQL = tcSQL
        cConnectionString = toConnection.ConnectionString
        Try
            oDataAdapter = New OleDbDataAdapter(tcSQL, toConnection)
So, basically, in this example, I have removed Shared from the Public line of oDataAdapter. So, in the SQLExec() method, I can no longer have access to oDataAdapter as it generates an error at design time.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform