Dispalying Welcome User to logged in user

M

mark

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

S.M. Altaf [MVP]

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

mark

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top