Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 January 29th, 2007, 10:36 AM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'Address' is not a member of 'Profile'

Hi Wrox,

First of all let me say how much I like this book. It is a really great help for us novices in learning about ASP.Net 2. Glad you wrote it! My problem is that I am trying to retrieve user data from Profiles by adding Address.Profile to Helpers.vb. But when I launch the site I get the error:

BC30456: 'Address' is not a member of 'Profile'.

I am not sure why I get this error as Profiles seem to be correctly set up. Does anyone have an idea what might be causing this? Many thanks in advance.

Fred

 
Old January 29th, 2007, 11:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Fred,

Glad you like the book.

Are you opening the site as is, or did you change anything?

When you look in the web.config file, do you see the Profiles section there? I assume this is about the Webshop application?

Maybe you have other errors in the web.config? When it's invalid, the ProfileCommon class won't be compiled, so Address is not available.

Finally, how do you browse to the site? Through the built-in web server or with IIS?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old January 29th, 2007, 11:15 AM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thanks for your speedy reply! Yes, I am using the WebShop, and yes, I have modified it a bit, nothing major. It is hooked up to a sql2000 database and all works fine. The Profiles section is in the web.config, as below:

    <profile enabled="true">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" connectionStringName="WebShop" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </providers>
      <properties>
        <add name="FirstName" />
        <add name="LastName" />
        <add name="ProfileCompleted" type="System.Boolean" />
        <group name="Address">
          <add name="Street" type="System.String" />
          <add name="ZipCode" type="System.String"/>
        </group>
      </properties>
    </profile>

And I am browsing with IIS. I don't think there are any errors in the web.config as I haven't changed much. The ProfileCommon class must be working as the registration/login process on the site works fine. It's only when I try to retrieve the Profile data that I have problems. Any help is greatly appreciated!

Fred

 
Old January 29th, 2007, 12:48 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Fred,

I think I am a bit thick today as it only occurred to me now what the problem is.
You're writing code in the App_Code folder, where stuff like Profile isn't available by default. However, there are at least two work arounds:

1. Have your function in Helpers accept a Profile object:

Public Shared Sub DoSomethingUseful(ByVal myProfile As ProfileCommon)
  ' Here, myProfile.Address is now available
End Sub

You can now call the Sub in an ASPX pgae like this:

Helpers.DoSomethingUseful(Profile)

2. If you can't or don't want to pass references to the Profile object, you can get one in app code like this:

Public Shared Sub DoSomethingUseful()
  Dim myProfile As ProfileCommon = CType(ProfileBase.Create(Membership.GetUser().User Name), ProfileCommon)

  ' Now, myProfile.Address is now available
End Sub

Although the name Create implies it creates a nw Profile, you actually get the one for the user retrieved by Membership.GetUser().

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old January 29th, 2007, 12:56 PM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Great! I'll try this out as soon as I can and let you know the result. Cheers.

Fred

 
Old January 29th, 2007, 06:36 PM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Yup, your solution worked perfectly! Thank you so much. I was trying to add data from Profiles to Helper.vb so that this info could be sent out with the confirmation email. I couldn't figure out how to fix it, but Dim myProfile As ProfileCommon = CType(ProfileBase.Create(Membership.GetUser().User Name), ProfileCommon) did the trick.

Fred

 
Old January 30th, 2007, 12:48 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Fred,

You're welcome....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile common bendjoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 13 October 12th, 2010 02:26 AM
Profile Management aspnet35 General .NET 0 October 29th, 2007 04:53 AM
Profile properties depending on the member type mecca BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 24th, 2007 04:43 PM
Profile in BLL Faith BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 14th, 2006 03:57 AM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





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