|
-
Jun 13th, 2009, 02:33 AM
#1
Thread Starter
New Member
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
-
Jun 13th, 2009, 10:36 AM
#2
Re: declaration expected error in class??
myOleDbAdapter has not been declared. The variable is declared as
myOleDbDataAdapter
-
Jun 13th, 2009, 07:35 PM
#3
Thread Starter
New Member
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)
-
Jun 13th, 2009, 07:44 PM
#4
Re: declaration expected error in class??
The variable name is myOleDbDataAdapter.
-
Jun 13th, 2009, 07:51 PM
#5
Thread Starter
New Member
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
-
Jun 13th, 2009, 08:03 PM
#6
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
Last edited by brucevde; Jun 13th, 2009 at 08:10 PM.
-
Jun 13th, 2009, 08:11 PM
#7
Thread Starter
New Member
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
-
Jun 13th, 2009, 08:23 PM
#8
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
-
Jun 13th, 2009, 09:01 PM
#9
Thread Starter
New Member
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
-
Jun 14th, 2009, 05:44 AM
#10
Thread Starter
New Member
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
-
Jun 14th, 2009, 02:16 PM
#11
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|