Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom User Profile PropertiesCustom User Profile Properties
Previous
 
Next
New Post
11/25/2007 5:07 AM
 

Hi

I'm still a little new to DNN so bear with me... I have a requirement to add a custom property to a user's profile. Here's what I wrote to take the user account, test for the existence of the property and add it if necessary: -

        Private Sub SetUserProperty(ByVal User As DotNetNuke.Entities.Users.UserInfo, ByVal PropertyName As String, ByVal Value As String)
            Dim ProfileProperty As DotNetNuke.Entities.Profile.ProfilePropertyDefinition

            ProfileProperty = User.Profile.ProfileProperties.GetByName(PropertyName)
            If (ProfileProperty Is Nothing) Then
                ProfileProperty = New DotNetNuke.Entities.Profile.ProfilePropertyDefinition
                ProfileProperty.PortalId = _PortalSettings.PortalId
                ProfileProperty.PropertyCategory = "BTS"
                ProfileProperty.PropertyName = PropertyName
                ProfileProperty.PropertyValue = Value
                ProfileProperty.Length = 255
                ProfileProperty.DataType = 349
                ProfileProperty.Visibility = UserVisibilityMode.AllUsers
                ProfileProperty.Visible = True
                User.Profile.ProfileProperties.Add(ProfileProperty)
            Else
                User.Profile.SetProfileProperty(PropertyName, Value)
            End If

         ProfileProvider.UpdateUserProfile(User)

        End Sub

This is the error I get: -

Error: BTS User Import is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UserProfile_ProfilePropertyDefinition". The conflict occurred in database "C:\LUKE\VISUAL STUDIO 2005\WEBSITES\DNN\APP_DATA\DATABASE.MDF", table "dbo.ProfilePropertyDefinition", column 'PropertyDefinitionID'. The statement has been terminated. ---> System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UserProfile_ProfilePropertyDefinition". The conflict occurred in database "C:\LUKE\VISUAL STUDIO 2005\WEBSITES\DNN\APP_DATA\DATABASE.MDF", table "dbo.ProfilePropertyDefinition", column 'PropertyDefinitionID'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues) at DotNetNuke.Security.Membership.Data.SqlDataProvider.UpdateProfileProperty(Int32 ProfileId, Int32 UserId, Int32 PropertyDefinitionID, String PropertyValue, Int32 Visibility, DateTime LastUpdatedDate) at DotNetNuke.Security.Profile.DNNProfileProvider.UpdateUserProfile(UserInfo user) at BTS.BTSServer.UpdateUser(String ContactID, DataRow Row) in C:\Luke\Visual Studio 2005\WebSites\DNN\App_Code\clsBTSServer.vb:line 189 at BTS.BTSServer.UploadContacts(String Criteria) in C:\Luke\Visual Studio 2005\WebSites\DNN\App_Code\clsBTSServer.vb:line 244 at Modules.BTSUserImport.View.btnImport_Click(Object sender, EventArgs e) in C:\Luke\Visual Studio 2005\WebSites\DNN\DesktopModules\BTSUserImport\View.ascx.vb:line 69 --- End of inner exception stack trace ---

Any help or advice appreciated.

Luke

 

 
New Post
11/25/2007 11:08 AM
 
I would be very interested to see how you managed to insert Profile properties. I have tried to do so unsuccessfully. I tried to use the Profile properties for Module Communication.
I posted yesterday on this issue but it has not been solved. See post on "how module communicate”. How did you know what “DataType” to put for the Profile property? Is this documented some place. In Debug mode I did see that properties of type text have DataType equal to 349. Are the Datatypes Documented some place?
I managed to insert the Profile property into the Profile. But it miraculously disappears from the profile because Profile properties are read from the Database.
Can somebody help, maybe point on some examples/documentation on profile properties and how and at which time to insert , so they are not overwritten by data read from DB.
 
New Post
11/25/2007 11:15 AM
 

why don't you simply add it using "Manage Profile Properties" in Admin :: User Accounts module to add your properties?


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/25/2007 5:22 PM
 

Hi  jipsen /  Sebastian

Thanks for your replies.

The nature of the properties I am adding is not known by the DNN module. They are being added from a remote database and I am not aware at the time of importing what they will be. All I know is the property name and value. This is why I need to find out how to add them via code only.

The reason I used a data type of 349 was, to be honest, a guess as other properties of a similar type appeared to use that value.

If anybody has any pointers or examples on how to set up user defined properties via code I'd be very grateful as this is causing a delay in my project.

Thanks!

Luke

 

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom User Profile PropertiesCustom User Profile Properties


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out