none
Pass data from Query into label RRS feed

  • Question

  • The below code works, however, I am trying to get the clientID and pass it back to a label:

     

    Dim txtPassR As String = txtPass.Text

    Dim txtEmailR As String = txtEmail.Text

    Dim txtClientR As String

     

    Using connLogin As New gpDataContext()

    Dim chkLogin = From m In connLogin.Members _

    Where m.memEMail = txtEmailR AndAlso _

    m.memPassword = txtPassR _

    Select New With {.memIDR = m.memID _

    , .clientIDR = m.clientID}

     

    txtClient.Text = "Loged In"

    cID.Text = chkLogin.clientIDR

    End Using

     

    TIA

     

     

    Saturday, July 19, 2008 4:37 AM

Answers

  • The query returns a sequence of objects, unless you explicitly ask for only one using a method like First() or Single( ).

     

    (Or, you need to execute the query using a 'for each' or a method like ToList( ).)

     

    Hope that helps,

     

    --Samir

     

    Monday, July 21, 2008 4:49 PM

All replies

  • I'm not sure I understand the question...can you please explain the problem?

     

    Thanks,

     

    --Samir

     

    Monday, July 21, 2008 4:35 PM
  • Let me simplify the code and see if that helps:

            Using connLogin As New gpDataContext()

                Dim chkLogin = From m In connLogin.Members _
                               Select m

     

    txtClient.Text = chkLogin.memID
    Session("memID") = chkLogin.memID

           

     End Using


    Within Members table I have a column name "memID". I want to gran that "memID" and place it into txtClient.Text / OR place it into a session variable.

    Monday, July 21, 2008 4:37 PM
  • The query returns a sequence of objects, unless you explicitly ask for only one using a method like First() or Single( ).

     

    (Or, you need to execute the query using a 'for each' or a method like ToList( ).)

     

    Hope that helps,

     

    --Samir

     

    Monday, July 21, 2008 4:49 PM
  •  

    Thanks - Got it Working - Working Code:

     

    Using connLogin As New gpDataContext()
                Try
                    Dim chkLogin = (From m In connLogin.Members _
                                    Where m.memEMail = memEmail AndAlso _
                                    m.memPassword = memPass _
                                    Select m).First()

                    System.Web.HttpContext.Current.Session("cID") = chkLogin.clientID
                    System.Web.HttpContext.Current.Session("mID") = chkLogin.memID
                    System.Web.HttpContext.Current.Session("auth") = "1"
                    auth = 1
                Catch ex As Exception
                    System.Web.HttpContext.Current.Session("auth") = "0"
                    auth = 0
                End Try

            End Using

    Tuesday, July 22, 2008 12:49 PM