Hi Owen,
I think you'll find the email address is stored in a different place in the
database. You can get at it using one of the built-in views.
Here's some code that might get you pointed in the right direction. It feels
like a hack, so please post any improvements? See the inline comments for
details.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET[
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArg s)
If Not IsPostBack Then
' By Ken Cox [Microsoft MVP]
' August 24, 2006
' Please improve on this hack! --kc
' Declare the dataview, sqldatasource
' and connection
Dim dv As New Data.DataView
Dim sqldsrc As New SqlDataSource
Dim connectionStrin gs As _
ConnectionStrin gSettingsCollec tion = _
System.Web.Conf iguration. _
WebConfiguratio nManager.Connec tionStrings
' Set the select command to use the built-in view
' and narrow the view down to the username
sqldsrc.SelectC ommand = "SELECT Email FROM " & _
"vw_aspnet_Memb ershipUsers WHERE (UserName = 'kencox')"
' Make sure we are treating it as a text
' query rather than as a stored procedure
sqldsrc.SelectC ommandType = SqlDataSourceCo mmandType.Text
' Tell the sqldatasource to return a dataset or datatable
sqldsrc.DataSou rceMode = SqlDataSourceMo de.DataSet
' Set the ID for good form
sqldsrc.ID = "sqldatasource1 "
' Fetch the connection string from the web.config
sqldsrc.Connect ionString = connectionStrin gs.Item _
("ASPNETDBConne ctionString").C onnectionString
' Get the retrieved data into the dataview by
' calling the Select method with no arguments
dv = sqldsrc.Select( DataSourceSelec tArguments.Empt y)
' Put the retrieved value from the "email" column
' into the label
Label1.Text = dv.Table.Defaul tView(0).Item(" email")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the email address of a Membership row</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<p>
<asp:labe l id="Label1"
runat="server"> </asp:label></p>
</div>
</div>
</form>
</body>
</html>
"Owen Richardson" <Ow************ @discussions.mi crosoft.comwrot e in
message news:B5******** *************** ***********@mic rosoft.com...
>I just started using The Login Objects and the CreateUserWizar d creates a
number of fields including Email address and i cant figure out how to
reference it: intellisense tells me that Profile.Usernam e is available, as
are all of my customised fieldnames - but where would i find the Email
Address?? All i want to do is assign the email address of the logged in
user
to a string
Regards
Owen