Hello -- I'm using asp.net 2 in visual web developer and I'm drawing a blank finding documentation on on this fairly simple task. Since this is the novice's thread, I felt bold enough to ask.
I'd like to programmatically retrieve a string from the aspnet_usermembership database -- the select statement would be something like the below. Can anyone point me at example code to do this programmatically -- so I end up with the LoweredEmail string from the DB? I guess I could either read it directly from the DB, or from a gridview control on the page -- but I'm new to SQL data manipulation and althoug I've seen examples nothing seems to work in this environment and it's probably simpler than I think to those who know what they;re doing..
Thanks for pointers.
"SELECT LoweredEmail FROM aspnet_Membership WHERE username=@dotnet.itags.org.Username"
Hey, just an idea. You can use SqlCommand.ExecuteScalar() to return a single value from database, assuming that your select SQL statment returns a scalar value. The method returns an object type so you need to comvert, in your case, a string type, like something below
...
dim LoweredEmail as String
dim SqlCmd as New SqlCommand("sql stmt", SqlConnObt)
LoweredEmail = CType(SqlCmd.ExecuteScalar(), String)
...
Thanks Bernie I'll give that a shot -- looks to be exactly what I needed.
Richard.
Worked fine -- just needed to do this in a two-stage process to get the GUID for the user from the username, which teyn gets teh email address. So added
Dim SqlEmailCmdAsNew SqlCommand("SELECT LoweredEmail FROM aspnet_Membership WHERE userid=@.Guid", myMembershipConnection)
SqlEmailCmd.Parameters.AddWithValue("@.Guid", userid)
0 comments:
Post a Comment