Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FirstName is not a member of Profile

Posted on 2008-10-22
10
Medium Priority
?
645 Views
Last Modified: 2013-11-07
I am trying to use the new Profile features in .Net 2.0. But when I enter the following I get an error saying that FirstName is not a member of Profile.

txtFirstName.text = Profile.firstname

Any ideas on what I'm missing? Thanks
<profile enabled ="true" defaultProvider="AspNetSqlProfileProvider">
      <providers>
        <add connectionStringName="LocalSqlServer" applicationName="/CoachingSource"
           name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
      <properties>
        <add name="FirstName" type="String" serializeAs="String" />
        <add name="LastName" type="String" serializeAs="String" />
        <add name="LastVisited" type="String" serializeAs="String" />
        <add name="Age" type="String" serializeAs="String" />
        <add name="Member" type="String" serializeAs="String" />
      </properties>
    </profile>

Open in new window

0
Comment
Question by:wilcor14
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22783142
use this

txtFirstName.text = Profile.FirstName
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22783159
As long as the above is under <system.web> the properties work fine as Profile.FirstName.  Not sure if case sensitive, but you can try.

Think when you specify a Sql provider or any provider for that matter, that the properties come from the provider and so the properties section is ignored.  Check if the database has the same properties in its table for profile.
0
 

Author Comment

by:wilcor14
ID: 22786011
Thanks for the help. I have the table set up but in apsnet_Profile, there is nothing in the table. Does that make a difference?
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:wilcor14
ID: 22786041
I went to the Web Site Administration tool and clicked on the provider tab. The only providers listed are those for membership and role management but nothing for profile management. Is this correct? Thanks.
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22789730
I believe you have to create it manually (through SQL) as these are custom properties.  Here is an example from Microsoft:
http://msdn.microsoft.com/en-us/library/8zs47k7y.aspx
0
 

Author Comment

by:wilcor14
ID: 22789929
mwvisa1

I don't think it has anything to do with my database since in my vb project I getting the erro that FirstName is not a member of Profile. Or not?
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22790391
Ok, well where is it suppose to get the structure of Profile object then?

You specified the database is the provider of the profile, so it must use the database to determine the structure.  At least that is my understanding.  If this is supposed to function otherwise, then hopefully someone knows how to get it working.

Hopefully you already tried making the property in case to match the property setup FirstName as suggested in case it is case sensitive.  Would not want you to waste time otherwise.

Anyhow, I apologize that I can't be more helpful, but my knowledge on this subject is limited to what I have already suggested. :(

Regards,
Kevin
0
 

Author Comment

by:wilcor14
ID: 22790655
Found a post that explains what the problem is. I am running a Web application.

I know web applications (as opposed to web sites) handle profiles a little differently because of the way things are compiled.  If you are using a web application we may have to find another way around this issue.


Here is the solution to grabbing a different users profile if you are using a web application.  Enjoy!

 In most of the code examples you have seen they use a ProfileCommon class.  That is because they are working with a website and that class is created while they are still developing.  That is also why they get intellisense when using profiles.  When using a web app the code won't compile until run time so we don't get the intellisense and we don't get the ProfileCommon class.  ProfileCommon's base class is ProfileBase.  We can use this class the same way they were to an extent.  Just look at the sample code below.  I think it will make sense.
Dim strUserName As String = Me.lstUsers.SelectedValue
Dim userProfile As ProfileBase = ProfileBase.Create(strUserName, True) 'if the user already has a profile this will just grab their profile, it won't overwrite it, don't worry
 
Me.txtFirstName.Text = userProfile.GetPropertyValue("FirstName")
Me.txtLastName.Text = userProfile.GetPropertyValue("LastName")
Me.txtEmailAddress.Text = Membership.GetUser(strUserName).Email 

Open in new window

0
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 total points
ID: 22790797
Glad you found what you needed.
0
 

Author Closing Comment

by:wilcor14
ID: 31509081
Thanks for the effort.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question