Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SQL Query for DotNetNuke Profile Fields

Posted on 2008-10-31
5
Medium Priority
?
1,811 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
  • 2
4 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 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Suggested Courses

577 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