Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2006

Tip: Looking for answers? Try searching our database.

Object reference not set to an instance of an object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pj - 13 Sep 2006 21:57 GMT
Can anyone help?  I getting this error on line 17:

Object reference not set to an instance of an object.

Line 15:         Dim UserGUID As Object = User.ProviderUserKey
Line 16:
Line 17:         DataSource.InsertParameters.Add("UserID",
UserGUID.ToString())
Line 18:         DataSource.Insert()

Here's my code:

   Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object,
ByVal e As System.EventArgs)

       Dim UserNameTextBox As TextBox =
CType(CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"),
TextBox)
       Dim DataSource As SqlDataSource =
CType(CreateUserWizardStep1.ContentTemplateContainer.FindControl("InsertExtraInfo"),
SqlDataSource)

       Dim User As MembershipUser =
Membership.GetUser(UserNameTextBox.Text)
       Dim UserGUID As Object = User.ProviderUserKey

       DataSource.InsertParameters.Add("UserID", UserGUID.ToString())
       DataSource.Insert()
       
   End Sub
Tim_Mac - 13 Sep 2006 22:58 GMT
hi pj,
you are calling a method on a null object, hence the Null reference
exception.  User.ProviderUserKey is null, so you can't call .ToString() on
it.
there must be something you are not initialising correctly with the user
object.  i suggest you read the SDK pages for this class to see how to set
it up correctly.

tim

> Can anyone help?  I getting this error on line 17:
>
[quoted text clipped - 26 lines]
>
>    End Sub
pj - 14 Sep 2006 00:31 GMT
.........i got it.....my datasource wasn't being initiated....duh!

pj, mcdba, mcp
Rob MacFadyen - 14 Sep 2006 00:36 GMT
pj,

The User variable likely has the value null. If the specified userid is not
known then Membership.GetUser(string) will return null.

Regards,

Rob MacFadyen

> Can anyone help?  I getting this error on line 17:
>
[quoted text clipped - 26 lines]
>
>    End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.