Dispalying Welcome User to logged in user

Discussion in 'ASP .Net Web Controls' started by mark, Oct 6, 2005.

  1. mark

    mark Guest

    Hello

    I want to display on a webpage Welcome Mark to a logged in user. Users login
    using their email address but I want to display their Name from the same
    table which stores email and password. Here is the code I'm using but it
    doesn't work.

    Sub Page_Load
    Dim conMyData As SqlConnection
    Dim cmdSelect As SqlCommand

    conMyData = New SqlConnection(
    "Server=mtsda;UID=user;PWD=password;Database=BAOL" ) conMyData.Open()
    cmdSelect = New SqlCommand("Select Login_Name From Provider_Login where (
    Provider_Email = <%=User.Identity.Name%>) ", conMyData )
    lblLogin_Name.Text = cmdSelect.ExecuteScalar()
    conMyData.Close()
    End Sub

    Appreciate your Help
     
    mark, Oct 6, 2005
    #1
    1. Advertising

  2. Try this:

    Sub Page_Load
    Dim conMyData As SqlConnection
    Dim cmdSelect As SqlCommand
    conMyData = New
    SqlConnection("Server=mtsda;UID=user;PWD=password;Database=BAOL" )
    conMyData.Open()
    cmdSelect = New SqlCommand("Select Login_Name From Provider_Login where
    (Provider_Email = '" & User.Identity.Name & "')", conMyData )
    lblLogin_Name.Text = cmdSelect.ExecuteScalar()
    conMyData.Close()
    End Sub

    HTH
    S.M. Altaf
    [MVP - VB]

    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    www.mendhak.com


    "mark" <> wrote in message
    news:...
    > Hello
    >
    > I want to display on a webpage Welcome Mark to a logged in user. Users
    > login using their email address but I want to display their Name from the
    > same table which stores email and password. Here is the code I'm using but
    > it doesn't work.
    >
    > Sub Page_Load
    > Dim conMyData As SqlConnection
    > Dim cmdSelect As SqlCommand
    >
    > conMyData = New SqlConnection(
    > "Server=mtsda;UID=user;PWD=password;Database=BAOL" ) conMyData.Open()
    > cmdSelect = New SqlCommand("Select Login_Name From Provider_Login where
    > ( Provider_Email = <%=User.Identity.Name%>) ", conMyData )
    > lblLogin_Name.Text = cmdSelect.ExecuteScalar()
    > conMyData.Close()
    > End Sub
    >
    > Appreciate your Help
    >
     
    S.M. Altaf [MVP], Oct 6, 2005
    #2
    1. Advertising

  3. mark

    mark Guest

    Thank you for your reply. It's still not working. I'm not getting any error
    on my page but I'm not getting User Name either . I'm using the following
    code on the page: Welcome <asp:label ID="lblLogin_Name" Runat="server"/> to
    dispaly the name in the HTML portion of the page - however all I'm getting
    is Welcome.
    I know I've DB connection I'm authenticated and I'm getting no errors.
    What could be wrong?

    Mark

    "S.M. Altaf [MVP]" <> wrote in message
    news:...
    > Try this:
    >
    > Sub Page_Load
    > Dim conMyData As SqlConnection
    > Dim cmdSelect As SqlCommand
    > conMyData = New
    > SqlConnection("Server=mtsda;UID=user;PWD=password;Database=BAOL" )
    > conMyData.Open()
    > cmdSelect = New SqlCommand("Select Login_Name From Provider_Login where
    > (Provider_Email = '" & User.Identity.Name & "')", conMyData )
    > lblLogin_Name.Text = cmdSelect.ExecuteScalar()
    > conMyData.Close()
    > End Sub
    >
    > HTH
    > S.M. Altaf
    > [MVP - VB]
    >
    > --------------------------------------------------------------------------------
    > All that glitters has a high refractive index.
    > www.mendhak.com
    >
    >
    > "mark" <> wrote in message
    > news:...
    >> Hello
    >>
    >> I want to display on a webpage Welcome Mark to a logged in user. Users
    >> login using their email address but I want to display their Name from the
    >> same table which stores email and password. Here is the code I'm using
    >> but it doesn't work.
    >>
    >> Sub Page_Load
    >> Dim conMyData As SqlConnection
    >> Dim cmdSelect As SqlCommand
    >>
    >> conMyData = New SqlConnection(
    >> "Server=mtsda;UID=user;PWD=password;Database=BAOL" ) conMyData.Open()
    >> cmdSelect = New SqlCommand("Select Login_Name From Provider_Login where
    >> ( Provider_Email = <%=User.Identity.Name%>) ", conMyData )
    >> lblLogin_Name.Text = cmdSelect.ExecuteScalar()
    >> conMyData.Close()
    >> End Sub
    >>
    >> Appreciate your Help
    >>

    >
    >
     
    mark, Oct 7, 2005
    #3
  4. naijacoder naijacoder, Oct 7, 2005
    #4
  5. mark

    mark Guest

    No The authentication is via SQL 2000 Table.

    "naijacoder naijacoder" <> wrote in message
    news:%23Qux%...
    > Are you using Windows Authenetication?
    > Patrick
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    mark, Oct 7, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    0
    Views:
    637
    keithb
    Feb 16, 2006
  2. Guest

    Dispalying asp pages

    Guest, Mar 31, 2006, in forum: ASP .Net
    Replies:
    10
    Views:
    690
    Nicolas Noakes
    Apr 19, 2006
  3. ...D.
    Replies:
    44
    Views:
    1,227
    SpaceGirl
    Jul 26, 2004
  4. Brian van den Broek

    mailing list welcome welcome msg in wiki suggestion

    Brian van den Broek, Dec 12, 2004, in forum: Python
    Replies:
    0
    Views:
    698
    Brian van den Broek
    Dec 12, 2004
  5. Replies:
    1
    Views:
    952
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
Loading...

Share This Page