Solved

SQL Query for DotNetNuke Profile Fields

Posted on 2008-10-31
5
1,754 Views
Last Modified: 2012-08-13
Greeting.  I am in the process of creating membership reports for a DotNetNuke portal with a few thousand members.  For the life of me, I can't seem to be able to add the entended profile fields to my query (attached).  I want to call members by roles and display extended profile fields like address and such.  The attached querry works perfectly with the caveat that it only pulls data from the default user table.  Any ideas on how to modify this code?  Thanks.

FOUND THE ANSWER ON THE FORUM.  For others with a similar question, follows is the sample query.
Select U.Username As [Krewe Number], U.FirstName As [First Name],
  R.RoleName As [Member Level], AM.Email As [E-Mail], (Select UP.PropertyValue
  From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 40) As [Costume Size]
From Users U Inner Join
  UserRoles UR On U.UserID = UR.UserID Inner Join
  Roles R On UR.RoleID = R.RoleID Inner Join
  Aspnet_users AU On U.Username = AU.UserName Inner Join
  Aspnet_membership AM On AU.UserId = AM.UserId
Where R.RoleName = 'Registered Users'

Open in new window

0
Comment
Question by:MarkNewOrleans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 22856138
this code is calling by Where R.RoleName = 'Registered Users'
what other roles are in the table?

0
 

Author Comment

by:MarkNewOrleans
ID: 22856402
For my purposes -- A Mardi Gras Krewe in New Orleans with over 3,000 members -- I use the above query to display extended profile fields from the core DNN profile tables and filter the results by Role.  I am actually using the above query in SQL Reporting Services to generate table relationships for reports. Works like a charm.  Attached is a better example of how I am using this statement.

Note that DotNetNuke stores profile data with a lot of complex table relationships. It's not for the weak at heart and can be very difficult for the "unitiated."

The attached SQL simplifies this for you.  But, you will still need to open the DNN ProfilePropertyDefenitions table and find the numeric value for each desired profile field.  I open the table once, sort the values one time using the TextName and the NumericFields and paste them into Notepad so I have an easy reference and just cut and paste the values I want to add to my reports.

To add profile fields use  the following expession:

 (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 28) As Costume Size,

Lines to note in the above code snippet:
PropertyDefinitionID = 28  

CHANGE "28" to the desired profile field from the values found in your DNN ProfilePropertyDefinition table.

Change the last line to the "Name of Role " you want use as a filter ----  CASE SENSITIVE ----

EXAMPLE: Where R.RoleName = 'Any User Role'

Best way for newbies to see how this works is to get a nice SQL Reporting tool and run the querry against their SQL table.  I actually started like this to speed up the learning curve in respect to all the table relationships in DotNetNuke.  It can be a lot to think about if your just getting started.  

I always say, It's "easy when you know how."

Happy Mardi Gras!

Select U.Username As [Krewe Number], U.LastName As [Last Name], U.FirstName As
  [First Name], AM.Email As [E-Mail], (Select UP.PropertyValue
  From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID =
    40) As [Costume Size], (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 28) As State,
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 27) As City,
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 26) As Address1,
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 45) As Address2,
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 39) As [Float Name],
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 30) As [Postal Code],
  (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID =
    70) As [Member Class], R.RoleName, (Select UP.PropertyValue
  From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 54) As [Member Level]
From Users U Inner Join
  UserRoles UR On U.UserID = UR.UserID Inner Join
  Roles R On UR.RoleID = R.RoleID Inner Join
  Aspnet_users AU On U.Username = AU.UserName Inner Join
  Aspnet_membership AM On AU.UserId = AM.UserId, vw_Users
Where (Select UP.PropertyValue From UserProfile UP
  Where U.UserID = UP.UserID And UP.PropertyDefinitionID = 70) =
  'Signature Float w/ Coronation 09' And R.RoleName = 'Krewe Member'

Open in new window

0
 
LVL 1

Expert Comment

by:cnelson67
ID: 23099213
I am also hunting down the a quick & easy DataType = Description reference table, I also must 'infer' the data type based on data in the table. I have tried searching for data type enums everywhere I can think of, but have yet to come up with this one. Please let me know should you find the answer,

In the mean time, for your report:

There are a number of stored procedures and functions used to operate on the ProfilePropertyDefinition table, including dbo.getUserProfile (UserID)

encapsulate the getUserProfile procedure by an outer query supplying userid and you will have all the profiles to match the userid for the report.

note - to discover other sp's etc, right click on any table and choose View Dependecies from Management Studio, all attached dependecies are noted along with related dependencies.

I will post the DataType reference should I discover one.
0
 
LVL 1

Accepted Solution

by:
cnelson67 earned 500 total points
ID: 23148011
FOUND - DNN ProfilePropertyDefinition.DataType enumeration.

This is implemented as a DNN List, It can be found on the Host tab under the List selection.

from the database, the following query will extract the list from dbo.Lists

Select * from dbo.lists where listname = 'DataType'

The value in the 'Text' field is a control type to be associated with the datatype for dynamic rendering.

Hope this helps.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question