Re: Reference to non-shared member???
From: Tim::.. (myatix_at_hotmail.com)
Date: 01/27/05
- Next message: z. f.: "aspx/html file bigger than 170KB truncated"
- Previous message: MWells: "Re: ISAPI filter or http module"
- In reply to: Eliyahu Goldin: "Re: Reference to non-shared member???"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 27 Jan 2005 02:41:03 -0800
Thanks...
"Eliyahu Goldin" wrote:
> A shared (static) method can't refered a non-shared member which User is.
>
> Either Remove Shared from the function definition, or use
> HttpContext.Current.User.
>
> Eliyahu
>
> "Tim::.." <myatix_at_hotmail.com> wrote in message
> news:0F9B2737-4782-4628-BF22-76E77D93A92E@microsoft.com...
> > Can someone please tell me why I get the following error in my code and
> how I
> > fix it!
> >
> > Error:
> > Reference to a non-shared member requires an object reference.
> >
> > I keep getting this error on
> >
> > objParam1.Value = User.Identity.Name
> >
> > Thanks
> >
> > Code..
> > Public Shared Function GetOfficeName() As String
> > Dim Myconn As New
> > SqlConnection(ConfigurationSettings.AppSettings("strConn"))
> > Dim cmd As New SqlCommand("UserDetails", Myconn)
> > cmd.CommandType = CommandType.StoredProcedure
> >
> > Myconn.Open()
> >
> > Dim objParam1 As SqlParameter
> > objParam1 = cmd.Parameters.Add("@UserName", SqlDbType.Char)
> > objParam1.Direction = ParameterDirection.Input
> > objParam1.Value = User.Identity.Name
> >
> > Dim myReader As SqlDataReader = cmd.ExecuteReader()
> > While myReader.Read()
> > If User.Identity.Name <> "" Then
> > Return myReader("offName")
> > End If
> > End While
> > ' always call Close when done reading.
> > myReader.Close()
> > ' Close the connection when done with it.
> > Myconn.Close()
> >
> > End Function
>
>
>
- Next message: z. f.: "aspx/html file bigger than 170KB truncated"
- Previous message: MWells: "Re: ISAPI filter or http module"
- In reply to: Eliyahu Goldin: "Re: Reference to non-shared member???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|