Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2007, 12:42 PM
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to SeanKilleen
Default Programmatically Access user's ASPNETDB E-Mail?

Hey all,

I've recently set up membership and profiles using the ASPNETDB structure, which I've ported over to a remote SQL 2005 DB.

I have a form where I need to access the current User's E-Mail and display that in a text box.

Is there a way to grab this value from the DB without having to set up an entire connection to it? I'm referring it to accessing it in a way similar to getting their first name by using my Profile.FirstName variable. If so, how does one do this?

Thanks in advance for any help you can give!

 
Old July 19th, 2007, 01:19 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

what's the code for your profile tags (in the web.config) look like?

I don't think FirstName is magical. I think Profile sends the application to the web.config, and FirstName has to be one of the items if finds there. That sends it to the database (it sets up the connection automatically from your web.config settings, but it's still hitting the DB) So if you have a profile item Email, then you can just call it the same way, Profile.Email

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old July 19th, 2007, 01:22 PM
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to SeanKilleen
Default

I'm not actually talking about the profile here; I'm referring more to retrieving the user's e-mail that is stored when the user is created through the built-in membership functionality, so it's not part of the profile.

But, in case you were asking for a different reason, the code is below:

Code:
    <profile defaultProvider="MyProfileProvider">
      <providers>
        <add name="MyProfileProvider"
         connectionStringName="LocalSqlServer"
         applicationName="/"
         type="System.Web.Profile.SqlProfileProvider" />
      </providers>
      <properties>
        <add name="FirstName" defaultValue="Unknown"/>
        <add name="LastName" defaultValue="Unknown"/>
        <add name="PhoneNumber" defaultValue="Unknown"/>
      </properties>

    </profile>


--
Sean Killeen
 
Old July 19th, 2007, 01:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

did you try this???
Code:
membership.GetUser("username").Email
HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 19th, 2007, 01:39 PM
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to SeanKilleen
Default

Worked Perfectly! One more similar question: What about the UserID that's stored in the DB? is it done by username or is there a numerical userID stored too?

--
Sean Killeen
 
Old July 19th, 2007, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

that i don't know... but there should be a userid (or something similar)...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
mail merge from access dfisher BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 1 October 17th, 2008 08:09 PM
Multiple user's cannot access the application nelly78 .NET Framework 2.0 4 July 21st, 2008 02:51 AM
ASPNETDB sanindia BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 27th, 2006 05:56 PM
localhost/aspnet access of the aspnetdb.mdf file rsearing ASP.NET 2.0 Basics 22 August 4th, 2006 02:28 PM
Access a Project's Property Pages Programmatically Jim Rogers Pro VB 6 0 March 2nd, 2004 02:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.