Wrox Programmer Forums
|
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 December 27th, 2006, 06:26 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default profile object

hey,
i already created a membership provider but now i'm trying to create me y own profile provider but i just can't get it to work

always when i do that

Dim _profile As ProfileCommon = ProfileCommon.Create(accountgegevens1.username)
            _profile.FirstName = Convert.ToString("Davy")
            _profile.Save()

then it give an error

it says

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 70: End Get
Line 71: Set
Line 72: Me.SetPropertyValue("FirstName", value)
Line 73: End Set
Line 74: End Property


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\root\c50537d4\da98326b\App_Code.ha81qb7p.4.v b Line: 72


i really try't evrything
in the web.config file i got this

<profile defaultProvider="custom_profile" enabled="true" automaticSaveEnabled="false">
      <providers>
        <add connectionstringname="db" name="custom_profile" type="custom_profile" />
      </providers>
      <properties>
        <add name="FirstName" />
        <add name="LastName" />
        <add name="BirthDate" />
        <add name="Gender" />
        <add name="Country" />
        <add name="MSN" />
        <add name="Xfire" />
        <add name="Teamspeak" />
        <add name="MSNEmailadres" />
        <add name="XfireUsername" />
      </properties>
    </profile>


greetz
 
Old December 28th, 2006, 05:59 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 there,

Did you code your own profile provider? If so, you need to provide more information about it in the <profile> section of web.config:
Code:
<profile enabled="true" defaultProvider="YourProvider">
  <providers>
    <add name="YourProvider"
       type="Your.NameSpace.YourProvider, YourAssembly"
       connectionStringName="YourConn"
       applicationName="AppName"
       description="Your Desc."/>
  </providers>
  <properties>
    ... properties here
  </properties>
</profile>
As you can see, this example also provides info about the name of the provider, namespace, assembly etc...

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 December 28th, 2006, 06:06 AM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah i did that i har a vb file like this

Public Class custom_profile
    Inherits ProfileProvider

    Public Overrides Property ApplicationName() As String
        Get

        End Get
        Set(ByVal value As String)

        End Set
    End Property

    Public Overrides Function DeleteInactiveProfiles(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal userInactiveSinceDate As Date) As Integer

    End Function

    Public Overloads Overrides Function DeleteProfiles(ByVal usernames() As String) As Integer

    End Function

    Public Overloads Overrides Function DeleteProfiles(ByVal profiles As System.Web.Profile.ProfileInfoCollection) As Integer

    End Function

    Public Overrides Function FindInactiveProfilesByUserName(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal usernameToMatch As String, ByVal userInactiveSinceDate As Date, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Profile.ProfileInfoCollection

    End Function

    Public Overrides Function FindProfilesByUserName(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal usernameToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Profile.ProfileInfoCollection

    End Function

    Public Overrides Function GetAllInactiveProfiles(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal userInactiveSinceDate As Date, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Profile.ProfileInfoCollection

    End Function

    Public Overrides Function GetAllProfiles(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Profile.ProfileInfoCollection

    End Function

    Public Overrides Function GetNumberOfInactiveProfiles(ByVal authenticationOption As System.Web.Profile.ProfileAuthenticationOption, ByVal userInactiveSinceDate As Date) As Integer

    End Function

    Public Overrides Function GetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal collection As System.Configuration.SettingsPropertyCollection) As System.Configuration.SettingsPropertyValueCollecti on
        HttpContext.Current.Response.Write("getpropertyval ue")
        return nothing
    End Function

    Public Overrides Sub SetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal collection As System.Configuration.SettingsPropertyValueCollecti on)
        HttpContext.Current.Response.Write("setpropertyval ue")
    End Sub
End Class

i use the HttpContext.Current.Response.Write("setpropertyval ue")
because i'm learning to work with the profile provider and want to know wich function being called and when they are called


 
Old December 28th, 2006, 06:09 AM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i just want to use a ms acces database because the sqlserver is 10 mb on his own and that's why i'm trying to create my default provider

 
Old December 28th, 2006, 06:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The 10MB you see is just the default for a new SQL Server database created in the App_Data folder of a website. It should be easy to create a blank new one of, say, 1MB, and then configure it for the ASP.NET services.

That said, take a look at this article: http://Imar.Spaanjaars.Com/QuickDocId.aspx?quickdoc=404

It explains how to use an Access database for ASP.NET services....

Hope this helps,

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 December 28th, 2006, 06:34 AM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is great i will look at it,
only problem is that it only uses c#
i don't know anything about c#
do they have acces providers in vb.net ???

 
Old December 28th, 2006, 07:50 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Unfortunately, no, there's only a C# version available.

However, if you only want to *use* the Access version, you don't need to look at the code; all you need to do is compile it.

If you do want to learn from the code, you indeed need to look into C#, although you'll find that a lot of the code is reasonably straight forward and deals a lot with accessing the database...

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.





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 in BLL Faith ASP.NET 2.0 Professional 3 August 18th, 2008 10:57 AM
Profile Management aspnet35 General .NET 0 October 29th, 2007 04:53 AM
Profile Query rain_uk Classic ASP Databases 1 June 1st, 2005 02:21 PM
Profile Pictures SerranoG Forum and Wrox.com Feedback 5 November 3rd, 2003 11:12 AM





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