declaration expected error in class??
ok i just finised writing out code configuration for a crystal report in visual studio 2008 visual basic language
this is in my datasetconfiguration.vb
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
End Get
End Property
Dim myDataSet As nrguestDataSetSchema = New nrguestDataSetSchema()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
myoledbadapter.Fill(myDataSet, DATATABLE_NAME)Return myDataSet
End Class
in my configuration file, my code keeps generating a single error message saying
declaration expected line 16 column 5 (red)
if u look at my code, i JUST DECLARED it in line 15 (yellow)
i even tried dropping of the "my" section in myoledbadapter and changed it to oledbadapter but still error.
what am i missing? im like ripping my hair out staring at it
please help, i've been trying to figure this out for the past three days.
i even followed the tutorial in the help file to the t and still that single error
Re: declaration expected error in class??
myOleDbAdapter has not been declared. The variable is declared as
myOleDbDataAdapter
Re: declaration expected error in class??
ok so i changed it
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
End Get
End Property
Dim myDataSet As nrguestDataSetSchema = New nrguestDataSetSchema()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
OleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)Return myDataSet
End Class
still getting that declaration error(red)
Re: declaration expected error in class??
The variable name is myOleDbDataAdapter.
Re: declaration expected error in class??
tried that
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
End Get
End Property
Dim myDataSet As nrguestDataSetSchema = New nrguestDataSetSchema()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
myOleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)Return myDataSet
End Class
same error
Re: declaration expected error in class??
Is this your entire class or just a partial code snippet?
Everything between End Property and End Class seems to belong in a procedure declaration (Property, Sub or Function etc).
Something like
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
End Get
End Property
Private Function DoSomething()
Dim myDataSet As nrguestDataSetSchema = New nrguestDataSetSchema()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
myOleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)
Return myDataSet
End Function
End Class
Re: declaration expected error in class??
its my entire class
do you reccommend that it be named as a public funtion or sub or like how should i write that line out
Re: declaration expected error in class??
Because of the Shared Property the code should probably be in the class constructor.
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Private Shared myDataSet As DataSet = New DataSet
Public Sub New()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
myOleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)
End Sub
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
Return myDataSet
End Get
End Property
End Class
To use the class and get the dataset you would write
Dim y As System.Data.DataSet
y = DataSetConfiguration.nrguestDataSet
Re: declaration expected error in class??
ok. but where would i implement that in at? and thank you for all ur help so far. i would have been sol for a while
Re: declaration expected error in class??
ok i changed it up, no error. heres what i have
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class DataSetConfiguration
Private Const CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aarons\Documents\Visual Studio 2008\Projects\APRAS\APRAS\nrguest.accdb"
Private Const QUERY_STRING As String = "SELECT * FROM nrguest"
Private Const DATATABLE_NAME As String = "nrguest"
Private Shared myDataSet As DataSet = New DataSet
Public Sub New()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)
Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)
Dim y As System.Data.DataSet
y = DataSetConfiguration.nrguestDataSet
myOleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)
End Sub
Public Shared ReadOnly Property nrguestDataSet() As DataSet
Get
Return myDataSet
End Get
End Property
End Class
when i click to view the crystal report, no data shows up, even when i edit the data base. all that shows are the column headings
Re: declaration expected error in class??
These two lines
Dim y As System.Data.DataSet
y = DataSetConfiguration.nrguestDataSet
were an example of how to use the DataSetConfiguation class. They were meant to be placed in another module. I don't use Crystal Reports in .NET but if the Report object has a DataSet property you might code
rpt.Dataset = DataSetConfiguation.nrguestDataSet