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