Re: Reference to non-shared member???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tim::.. (myatix_at_hotmail.com)
Date: 01/27/05


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
>
>
>



Relevant Pages

  • Re: How to retrive value that is invisible in gridview
    ... On Sep 5, 3:30 am, "Eliyahu Goldin" ... Visible=true and hide the control with a css rule display:none. ... invisible in gridview. ... string value1 = ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: Multiple Keyword Search using SQL PROC
    ... "Eliyahu Goldin" wrote: ... Pass one string and parse it in the sp. ... >> build the WHERE clause in the code behind and send it to the proc. ... >> David Lozzi ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to retrive value that is invisible in gridview
    ... "Eliyahu Goldin" wrote in ... I can retrieve the value from gridview but i cann't if the value is ... string value1 = ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: listbox and sql stored procedure
    ... Concatenate the values in a string delimited with some other string like "|" e.g.1|2|3. ... Pass this string to a stored procedure. ... Use charat function to extract individual numbers and the fire delete statements. ... "Eliyahu Goldin" wrote: ...
    (microsoft.public.dotnet.framework.aspnet)