dataset question

jvcoach23

Well-known member
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
Im trying to create a public class within my form1. Im going to be using it (my goal anyway) inside this class so that I can call this class from a thread.start. Anyway.. when I try to tell my dataset where to get the data from, it give me an error of declaration expected. If I use the same syntax outside of this class, just with my form class it works fine. What am I not understanding and how do I fix it.

Code:
Public Class TestingClass
Dim ds as new DataSet
ds = dlPerfmon.spServer(company, server)
End Class

thanks
 
i would imagine it is in this line:

Code:
ds = dlperfmon.spserver(company, server)

Company and server are variable values right? but there is no declaration for these inside inside your class
 
stustarz said:
i would imagine it is in this line:

Code:
ds = dlperfmon.spserver(company, server)

Company and server are variable values right? but there is no declaration for these inside inside your class

thanks for the replie.. I had tried that already.. something like this.
Code:
 Public Class TestingClass
        Private mvcServer As String
        Private mvcCompany As String

        Public Property vcServer() As String
            Get
                Return mvcServer
            End Get
            Set(ByVal pvcServer As String)
                mvcServer = pvcServer
            End Set
        End Property
        Public Property vcCompany() As String
            Get
                Return mvcCompany
            End Get
            Set(ByVal pvcCompany As String)
                mvcCompany = pvcCompany
            End Set
        End Property

        hold perfmon info
        Dim vcCategoryName As String
        Dim vcCounterName As String
        Dim vcInstance As String
        Dim intTblPMInstanceId As Integer

        create dataset to hold the perfmon counters to query
        Dim ds As New DataSet

        create a row container to step through dataset
        Dim dr As DataRow

        grab the info from dll for the counters to query
        ds = wsPerfmon.spPMCategoryInfoForOneServer(vcCompany, vcServer)

    End Class
I dont understand the error to know what Im doing wrong.. hope you have another idea..
thanks
shannon
 
You need to put the line
Code:
ds = dlperfmon.spserver(company, server)
inside a method - you cannot execute code like that at the class level.
 
I have tried creating a class like this
Code:
Namespace pf
    Public Class pfGather
        Public Sub New()
        End Sub
        Public Sub New(ByVal vcCategoryName As String, ByVal vcCounterName As String, ByVal intTblPMInstanceId As Integer, ByVal vcInstance As String)
            mvcCategoryName = vcCategoryName
            mvcCounterName = vcCounterName
            mintTblPMInstanceId = intTblPMInstanceId
            mvcInstance = vcInstance
        End Sub
        Private mvcCategoryName As String
        Private mvcCounterName As String
        Private mintTblPMInstanceId As Integer
        Private mvcInstance As String

        Public Property vcCategoryName() As String
        Public Property vcCounterName() As String
        Public Property vcInstance() As String
        Public Property intTblPMInstanceId() As Integer
    End Class
End Namespace
and
Code:
Namespace pf
    Public Class pfGathers
        Inherits ArrayList
        Public Sub New()
        End Sub
    End Class
End Namespace
and
Code:
Imports System.Diagnostics.PerformanceCounter
Imports System.Diagnostics.PerformanceCounterCategory

Namespace pf
    Public Class pfGatherMethod
        Public Function pfGather(ByVal vcServer As String, ByVal vcCompany As String) As pfGathers
            Dim opfGather As pfGather
            Dim opfGathers As New pfGathers
            Dim wsPerfmon As New Performance.Perfmon
            Dim ds As DataSet
            ds = wsPerfmon.spPMCategoryInfoForOneServer(vcCompany, vcServer)

            Dim WithEvents oCounter1 As New PerformanceCounter

            Dim Counter1 As Integer
       

        End Function
    End Class
End Namespace
and then I can create the ds. can you give me a quick explination on why this differs..I have my own idea.. but would like to hear from someone whos already banged their head till the light comes on.

when i did it like this.. then it doesnt want me to do the dim withevents.. tells me withevents is not valid on a local variable declaration.. but the performancecounter wants it..

so much to learn
 
You cannot use WithEvents on a variable declared with a method body - only at the class level.
As to why it now lets you create an instance of ds its like I said before - you cannot execute code outside of a method body, the assignment you where trying to do needed to be in a method.
 
Back
Top