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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Help with SQL QueryHelp with SQL Query
Previous
 
Next
New Post
2/5/2007 12:00 PM
 

I recently updated from v3.2.2 to v3.3.7 and, since then, the query we've been using to populate an employee directory isn't working right.  For some reason, all new users aren't showing up (although all existing users are, but without any of the custom dnn profile field information).

I was hoping someone could look at this query and let me know what I'm missing.  All I want to do is list out the employee name, phone, fax, location, department, and title (the latter 3 being new dnn profile fields based on lists).

SELECT DISTINCT
'<b>' + dbo.GetProfileElement('FirstName',PropertyNames,PropertyValuesString) + '</b>' AS First_Name,
'<b>' + dbo.GetProfileElement('LastName',PropertyNames,PropertyValuesString) + '</b>' AS Last_Name,
'<b>' + dbo.GetProfileElement('Telephone',PropertyNames,PropertyValuesString) + '</b>'  AS Telephone,
dbo.GetProfileElement('Fax',PropertyNames,PropertyValuesString) AS Fax,
dbo.GetProfileElement('Location',PropertyNames,PropertyValuesString) AS Location,
dbo.GetProfileElement('Department',PropertyNames,PropertyValuesString) AS Dept,
dbo.GetProfileElement('JobTitle',PropertyNames,PropertyValuesString) AS Title
FROM aspnet_users au
INNER JOIN aspnet_membership am ON au.userid = am.userid
INNER JOIN aspnet_profile ap ON ap.userid = am.userid
INNER JOIN aspnet_usersinroles ar ON ar.userid = am.userid
WHERE au.UserName != 'admin'
ORDER BY Last_Name

I'll be the first to admit I'm not up to speed on the new user tables and stored procedures, what they are, or how they work exactly ...I just need to fix this quickly and do the research later.  We use SQLGridSelectedView to lay out the table and provide search and filter capabilities.  It works, or has worked, really well for us.

Any help would be greatly appreciated.

 
New Post
2/5/2007 3:30 PM
 

I believe in 3.3.7, the Profile properties were moved to the ProfilePropertyDefinition (this change was affected before 3.3.7) but the ASPNET_PROFILE tables are blank in 3.3.7. If memory serves me right, this change was done back in 3.3.2 - someone from the core can correct me if this is incorrect.


AcuitiDP - Oracle Data Provider for DotNetNuke
 
New Post
2/5/2007 9:33 PM
 
Here is something that should work...
 
Select
  U.UserID
  ,'First Name' = (Select top 1 PropertyValue from UserProfile where UserID = U.UserID
                   and PropertyDefinitionID = (select PropertyDefinitionID from ProfilePropertyDefinition
                                               where PortalID = 1 and PropertyName = 'FirstName'))
  ,'Last Name' = (Select top 1PropertyValue from UserProfile where UserID = U.UserID
                   and PropertyDefinitionID = (select PropertyDefinitionID from ProfilePropertyDefinition
                                               where PortalID = 1 and PropertyName = 'LastName'))
  ,'Telephone' = (Select top 1 PropertyValue from UserProfile where UserID = U.UserID
                   and PropertyDefinitionID = (select PropertyDefinitionID from ProfilePropertyDefinition
                                               where PortalID = 1 and PropertyName = 'Telephone'))
From
  Users U,
  UserPortals p
Where
  U.UserID = P.UserID
  and P.PortalID = 1
Order by
  U.UserID
 
I have just done 3 items from the User Profile.  You can certainly extended this to add the addition property value you are looking for.  Also, the PropertyDefintionID could be hard coded or the entire select placed in a Stored procedure where the values could be calculated and supplied to the select.   You will also need to define the appropriate portal ID - I used 1 in the sample.
 
I tested this on my Tressleworks site and discovered I have some duplicate entries -- that may have been of my own doing - so I had to added the "TOP 1" in the sub-select to eliminate the duplicates - So you can probably remove the "TOP 1" - but it will not hurt anything to leave them.
 
Hope this helps
Paul.
 
New Post
2/6/2007 8:57 AM
 

Fantastic job, thanks a million for the help.  I modified what you did based on some of your suggestions you sent in your email and came up with the query below and it seems to work (I just have to fill in all of the profile information for all of my users):

Select
  'First Name' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 41),
  'Last Name' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 23),
  'Telephone' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 31),
  'Fax' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 33),
  'Location' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 39),
  'Department' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 46),
  'Title' = (Select PropertyValue from UserProfile where UserID = U.UserID and PropertyDefinitionID = 45)
From
  Users U,
  UserPortals p
Where
  U.UserID = P.UserID and P.PortalID = 0
Order by
  'Last Name'

 

You are a life-saving-SQL-God.
 
New Post
2/6/2007 5:36 PM
 

Glad to help, just remeber or for others reviewing the select, the hardcoded PropertyDefinitionIDs are valid for a specific site and will not work on a different Portal Number.  But once determined are stable for your site. 

Paul.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Help with SQL QueryHelp with SQL Query


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