Solved

SQL statement for dotnetnuke user profile reports

Posted on 2008-10-30
3
468 Views
Last Modified: 2012-05-05
The code snippet provided below works. I am trying to build a report from the typical ASP .NET user profile definitions and I don't know how to go about it.

In the code below I have defined INNER JOIN UserProfile UP on U.Userid = UP.UserID
In this table there is a field to define as  UP.PropertyDEfinitionID
Now depending on the value of this field example:
Possible values:
35 = Company Name
31 = Phone
33 = Fax
... and so on.

THEN I want to add a column name corresponding to the PropertyDEfinitionID value (eg Company) and set the column value to the next field called PropertyValue

So I would assume that the definition of PropertyValue  would be UP.PropertyValue

The outcome of my report would be:
username
firstname
lastname
rolename
email
AND THEN ...
Company
Phone
Fax
AND SO ON  ......


Urgent help required ...




SELECT U.Username, U.Firstname, U.Lastname, R.Rolename, AM.Email 

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

 

INNER JOIN UserProfile UP on U.Userid = UP.UserID

Open in new window

0
Comment
Question by:siacom
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
calpurnia earned 500 total points
ID: 22846571
Is this the sort of thing you're after?

SELECT U.UserID, (SELECT UP.PropertyValue FROM UserProfile UP WHERE U.UserID=UP.UserID and UP.PropertyDefinitionID=35) AS Company, (SELECT UP.PropertyValue FROM UserProfile UP WHERE U.UserID=UP.UserID and UP.PropertyDefinitionID=31) AS Phone
FROM Users U;
0
 

Author Closing Comment

by:siacom
ID: 31511908
Yes that works fine, thank you.
After posting the question I also resolved it with this statement:
SELECT TOP (100) PERCENT
Company.PropertyValue  AS Company,
dbo.Users.LastName     AS [Last Name],
dbo.Users.FirstName    AS [First Name],
Street.PropertyValue   AS Street,
Suburb.PropertyValue   AS Suburb,
State.PropertyValue    AS State,
Postcode.PropertyValue AS Postcode,
Phone.PropertyValue    AS [Phone],
dbo.Users.Email

FROM dbo.Users INNER JOIN
     dbo.UserProfile AS Street ON dbo.Users.UserID = Street.UserID AND
                        Street.PropertyDefinitionID = '26' LEFT OUTER JOIN
     dbo.UserProfile AS Suburb ON dbo.Users.UserID = Suburb.UserID AND
                        Suburb.PropertyDefinitionID = '27' LEFT OUTER JOIN
     dbo.UserProfile AS State ON dbo.Users.UserID = State.UserID AND
                        State.PropertyDefinitionID = '28' LEFT OUTER JOIN
     dbo.UserProfile AS Postcode ON dbo.Users.UserID = Postcode.UserID AND
                        Postcode.PropertyDefinitionID = '30' LEFT OUTER JOIN
     dbo.UserProfile AS Phone ON dbo.Users.UserID = Phone.UserID AND
                        Phone.PropertyDefinitionID = '31' LEFT OUTER JOIN
     dbo.UserProfile AS Company ON dbo.Users.UserID = Company.UserID AND
                        Company.PropertyDefinitionID = '35'
ORDER BY Phone

both statement work fine.
0
 

Author Comment

by:siacom
ID: 22846646
ONe other question, the statements work well in SQL manager.

I wanted to do a report ion Microsoft Access, and the syntax is not recognised. What would be the equivalent syntax for Ms Access with the same sql tables linked ??

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

862 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now