CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: NewsGroup Date Entered: 10/23/2005 7:12:55 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 33 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
rcurtis
Asp.Net User
Personalization - Object reference not set to an instance of an object10/23/2005 7:12:55 PM

0/0

I am trying to get a Custom personalization provider to work with my existing SQL table. When I try and call <%= Profile.CompanyName %> in the page I get

Object reference not set to an instance of an object.
Line 40:     Public Overridable Property CompanyName() As String
Line 41: Get
Line 42: Return CType(Me.GetPropertyValue("CompanyName"),String)
Line 43: End Get
Line 44: Set
What do I need to do to retrieve Profile values from my table?

Here's the GetPropertyValues from the class

Public Overrides Function GetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal ppc As System.Configuration.SettingsPropertyCollection) As System.Configuration.SettingsPropertyValueCollection

            Dim connString As String
            connString = "Server=xxx;User ID=xxx;password=xxx;Database=xxx"
            Dim commString As String
            commString = "SELECT CompanyID, CompanyName, Email from Company WHERE Userid = 123123123"
            Dim conn As SqlConnection = New SqlConnection(connString)
            Dim cmd As SqlCommand = New SqlCommand(commString, conn)

            ' Open the connection and execute the reader
            conn.Open()
            Dim reader As SqlDataReader
            reader = cmd.ExecuteReader()

            While reader.Read()
                ppc("CompanyID").DefaultValue = reader("CompanyID")
                ppc("CompanyName").DefaultValue = reader("CompanyName")
                ppc("Email").DefaultValue = reader("Email")
            End While

            ' Close connections
            reader.Close()
            conn.Close()
            cmd = Nothing

        End Function

rcurtis
Asp.Net User
Re: Personalization - Object reference not set to an instance of an object10/25/2005 11:15:31 PM

0/0

I was able to solve my own problem. The code I used about is from the book ASP.NET 2.0 the beta version and I couldn't get it to work as it is written up in the book. I used code based on another posting in this form which works fine. It works if the CompanyID is hardcoded into the SQL statement. What I need to do next is to capture the CompanyID from the Logged in member and pass it to the GetPropertyValues function. Any clues?


 Public Overrides Function GetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal ppc As System.Configuration.SettingsPropertyCollection) As System.Configuration.SettingsPropertyValueCollection

            Dim svc As SettingsPropertyValueCollection = New SettingsPropertyValueCollection()

            Dim connString As String
            'Dim Username As String
            'Dim password As String
            'Dim CompanyID As Integer
            'Dim CompanyName As String
            'Dim Email As String
            connString = "Server=xxxx;User ID=xxx;password=xxx;Database=xxxx"
            Dim commString As String
            commString = "SELECT CompanyID, CompanyName, Email from Company WHERE CompanyID = 1"
            Dim conn As SqlConnection = New SqlConnection(connString)
            Dim cmd As SqlCommand = New SqlCommand(commString, conn)
            'cmd.Parameters.Add("@UserID", SqlDbType.VarChar).Value = "123123123"
            'cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = password

            ' Open the connection and execute the reader
            conn.Open()
            Dim reader As SqlDataReader
            reader = cmd.ExecuteReader()

            While reader.Read()

                For Each prop As SettingsProperty In ppc
                    Dim pv As SettingsPropertyValue = New SettingsPropertyValue(prop)

                    Select Case prop.Name
                        Case "CompanyID"
                            pv.PropertyValue = reader("CompanyID")
                        Case "CompanyName"
                            pv.PropertyValue = reader("CompanyName")
                        Case "Email"
                            pv.PropertyValue = reader("Email")
                    End Select
                    svc.Add(pv)
                Next

            End While

            Return svc

            ' Close connections
            reader.Close()
            conn.Close()
            cmd = Nothing

        End Function

2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Active Media Technology: 6th International Computer Science Conference, AMT 2001, Hong Kong, China, December 18-20, 2001 : Proceedings Authors: Jiming Liu, Pong C. Yuen, Chung-hung Li, Joseph Ng, Toru Ishida, Pages: 402, Published: 2001
Personal Information Management Authors: William P. Jones, Jaime Teevan, Pages: 334, Published: 2007
IPCC 2001: Communication Dimensions : Proceedings : IEEE International Professional Communication Conference : Santa Fe, New Mexico, October 24-27, 2001 Authors: conference International professional commu, IEEE Professional Communication Society, IEEE Professional Communication Society, Society Professional Communication, Pages: 470, Published: 2001
The Internet Encyclopedia, 3 Volume Set Authors: Hossein Bidgoli, Pages: 2688, Published: 2004
Multimedia: Advanced Teleservices and High-speed Communication Architectures : Second International Workshop, IWACA '94, Heidelberg, Germany, September 26-28, 1994 : Proceedings Authors: Ralf Steinmetz, Pages: 449, Published: 1994
Web-based Intelligent E-learning Systems: Technologies and Applications Authors: Zongmin Ma, Pages: 388, Published: 2006
The Practical Handbook of Internet Computing Authors: Munindar Paul Singh, Pages: 1144, Published: 2005
Echoes from the Poisoned Well: Global Memories of Environmental Injustice Authors: Sylvia Hood Washington, Heather Goodall, Paul C. Rosier, Pages: 433, Published: 2006
Contemporary Jungian Clinical Practice Authors: Elphis Christopher, Hester Solomon, Hester McFarland Solomon, Pages: 384, Published: 2003
EDUTECH: Where Computer-Aided Design Meets Computer-Aided Learning Authors: Carlos Delgado Kloos, Abelardo Pardo, Pages: 227, Published: 2004

Web:
object reference not set to an instance of an object - ASP.NET Forums object reference not set to an instance of an object. Last post 09-29-2008 11:30 AM by che3358. 1 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Custom Profile Provider - Object reference not set to an instance ... Message : Object reference not set to an instance of an object. Source : App_Code Help link : Data : System.Collections. ...
WebJam Bags $2 Million for Community of Personalized Pages Mar 28, 2007 ... Their personalized pages are a form of self expression, not a start page, ... Object reference not set to an instance of an object. ...
Personalization and AJAX - Software FX Community I'm trying to understand Personalization feature and AJAX in Chartfx .... NullReferenceException: Object reference not set to an instance of ...
STSADM Custom Extensions: Personalization Service Permissions Minor bug: if you enter an invalid SSP name, you get an "Object reference not set to an instance of an object" instead of a more specific error message. ...
Object reference not set to an instance of an object. > DotNetNuke ... Forums > Product Discussion - DotNetNuke Modules > Dynamic Registration > Object reference not set to an instance of an object. ...
"Object reference not set to an instance of an object ... Now, when user A uses this page to register user B, he submits the form and gets an error saying "Object reference not set to an instance of ...
Scott Vintinner's Blog: StockQuotes - A replacement stock quote ... Some web part zones do not permit personalization (for example, .... NullReferenceException: Object reference not set to an instance of an object. at ...
Extending WebSphere Portal V6 personalization capabilities: Part 1 ... Feb 7, 2007 ... Serializable and thread-safe objects are not necessary if the object is put on the request, but then you will create a new instance of this ...
Server Error after cs2007 upgrade attempt - Community Server Object reference not set to an instance of an object. ... profile, and role manager in it (no health monitoring or personalization). ...




Search This Site:










solpart menu jumping problem?

how much longer will classic asp be supported ?

very confusing: how does <authorization> in web.config work?

display html code in freetextbox

dynamically change number of tabs on tabstrip

creating a standalone web project

how to clear a message after addmodulemessage

event calender control problem

how to dynamic load asp.net user controls in visual studio 2005

treeview events with autopostback=false

logout is not working

the d word - db2

httpcontext.current.user.identity.name is null on the server

integrated authentication and basic authentication

web form non-partial template?

how to create msi file for web application project

request.isauthenticated returns false!

custom menu control, sitemap provider and key

login control - creating new user questions

can't dowload the gcn from www.gotdotnet.com

'photo of the day' <asp:formview does not show on default start page

lost drag and drop capabilities from the tool box

looking for old ibs implementation

retrieving user info from dotnetnuke

calling profile.getprofile(string) without setting lastactivitydate

very large treeview

vs2005 dataset designer bug?

windows authentication

need help with a sql command please!

visual web developper installed and after that sql server 2005. overdone?

 
All Times Are GMT