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

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Where is the profile data?Where is the profile data?
Previous
 
Next
New Post
6/18/2010 7:07 PM
 
I’m not sure if this is the proper forum for this question so please accept my apology in advance.  I have created an additional profile item to collect information from a user.  Now I am trying to find out how to retrive the value of that information using a sql statement.  Can anyone tell me which table DNN5 stores the user profile information?  Thanks in advance.
 
New Post
6/18/2010 8:31 PM
 

User profile property values are stored in the database table UserProfile and profile property definitions in the table ProfilePropertyDefinition. Given an integer UserID and the profile property name, an SQL query similar to the following should work. Be sure to replace the {databaseOwner} and {objectQualifier} tokens with those used by your site. If you are running the query in the Host-->SQL dialog, checking the "Run as Script" box will automatically do the replacements for you.

DECLARE @UserID int
DECLARE @PropertyName nvarchar(50)

SET @UserID = 3
SET @PropertyName = 'City'

SELECT
     PropertyName,
     'PropertyValue' = Case When (PropertyValue Is Null) Then PropertyText Else PropertyValue End

FROM {databaseOwner}{objectQualifier}UserProfile UP
           Join {databaseOwner}ProfilePropertyDefinition PPD On UP.PropertyDefinitionID = PPD.PropertyDefinitionID

WHERE UP.UserID = @UserID AND PPD.PropertyName=@PropertyName

Note that the above query does not take into account that the profile property definition may have included a DefaultValue which should be returned for user's who have not supplied a value for the profile property.

I would also strongly caution against directly accessing core database tables as I have done in this example if you are retrieving the profile property value in a custom module. In that case, access to the profile property values should be done through the Profile property of the UserInfo object. The Profile property returns a ProfileProperty object which provides methods such as GetPropertyValue and SetProfileProperty. Because core tables and core stored procedures are subject to change with version upgrades, it is much more preferable to make use of core API's whenever possible. Only use direct access to core tables when you must design an SQL query such as when using the reports module.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
6/18/2010 9:45 PM
 
I found this in another post -- worked great for me: value = GetProfilePropertyValue(fieldYouWantToRetrieve).ToString() Function GetProfilePropertyValue(ByVal propertyName As String) As String Dim value As String Dim ppd As ProfilePropertyDefinition = UserInfo.Profile.GetProperty(propertyName) If ppd Is Nothing Then value = "" Else value = ppd.PropertyValue If value Is Nothing Then If String.IsNullOrEmpty(ppd.DefaultValue) Then value = String.Empty Else value = ppd.DefaultValue End If End If End If Return value End Function
 
New Post
6/18/2010 10:45 PM
 

I found this in another post -- worked great for me:
 
value = GetProfilePropertyValue(fieldYouWantToRetrieve).ToString()
Function GetProfilePropertyValue(ByVal propertyName As String) As String 

    Dim value As String 
    Dim ppd As ProfilePropertyDefinition = UserInfo.Profile.GetProperty(propertyName) 

    If ppd Is Nothing Then 
        value = "" 
    Else 
        value = ppd.PropertyValue 
        If value Is Nothing Then 
            If String.IsNullOrEmpty(ppd.DefaultValue) Then 
                value = String.Empty 
            Else 
                value = ppd.DefaultValue 
            End If 
        End If 
    End If
Return value
End Function

 
New Post
6/19/2010 5:40 AM
 
Thank you both William and Chuck. Exactly what I needed to solve my problem.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Where is the profile data?Where is the profile data?


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