Hi Gregory
Here is my complete code from the code behind file for my user control
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.OleDB
Imports System.Web
Namespace PS
Public Class CategoryList
Inherits UserControl
public RepDocs as DataList
sub Page_load (o as Object, E as eventargs) handles mybase.Load
RenderMenu
end sub
sub RenderMenu
repDocs.DataSource=MyQueryMethod()
repDocs.DataBind()
end sub
shared Function MyQueryMethod() As OleDBDataReader
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data
Source=C:\InetPub\wwwroot\PersonnelSolutions\Data\ documents.mdb"
Dim dbConnection As New OleDbConnection(connectionString)
Dim queryString As String
Dim dbCommand As New OleDbCommand
QueryString= "SELECT [DocId], [DocName], [DocDescription],
[Price],[DocCategory] FROM [tDocuments] " _
& "WHERE [DocCategory]=@Cat"
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dim ParaCategory as new oledbParameter
ParaCategory.Value=request.querystring("CatID") '**** this is the
error line ****
ParaCategory.ParameterName="@Cat"
ParaCategory.dbType=dbType.Int32
dbCommand.Parameters.Add(ParaCategory)
dbConnection.Open
Dim dataReader As OleDBDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
End Class
End Namespace
I think I understand what you mean regarding the different types of
methods/properties to to be honest I don't which object I to to instantiate
to create teh Request object. Dim (ing) an new Request object also throws an
error.
Thanks in advance
Nick
"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:91**********************************@microsof t.com...
You have two types of methods and properties. The first are class
methods/properties, which are Shared or static. The second are instance
methods/properties, which require you to create an object from your class
to
access them.
I do not see the code where you are pulling the item from Request, but
this
is where I would look. You may have the applicaiton set up where it
requires
instantiating the Request object before pulling items from it. Post a bit
more code to get a more specific answer.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Nick" wrote:
I've created a user control that extracts data from a database.
The VB code is all contained in a code-behind file.
I'm trying to extract a value from the request.querystring but keep
getting
the following error:
Description: An error occurred during the compilation of a resource
required
to service this request. Please review the following specific error
details
and modify your source code appropriately.
Compiler Error Message: BC30369: Cannot refer to an instance member of a
class from within a shared method or shared member initializer without an
explicit instance of the class.
Source Error:
Line 40:
Line 41: dim ParaCategory as new oledbParameter
Line 42: ParaCategory.Value=request.querystring("CatID")
Line 43: ParaCategory.ParameterName="@Cat"
Line 44: ParaCategory.dbType=dbType.Int32
I'm very new to this so I've probably made a really simple mistake.
I have the following imports at in my code.
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.OleDB
Imports System.Web
Which class is the Error referring to?
Any help would be greatly appreciated.
Thanks
Nick