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

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsSQL HELP!SQL HELP!
Previous
 
Next
New Post
11/14/2007 2:31 PM
 
SQL HELP!  Modified By Tony Boye  on 11/14/2007 2:32:18 PM

Hi,

Im getting Crazy here. Im trying to drag information about User, Role And UserProfile on one specific user.

This is the out put i want:

RoleName ExpireDate PropertyValue PropertyValue

My problem is, i cant get two different PropertyValues or atleast not without getting two rows. This is an exampel of my SQL script:

SELECT Roles.RoleName as Subscription,  UserRoles.ExpiryDate as Expire, UserProfile.PropertyValue as Server, UserProfile.PropertyValue as Administration FROM Users
  INNER JOIN UserRoles on UserRoles.UserId = Users.UserId
  INNER JOIN Roles on UserRoles.RoleId = Roles.RoleId
  INNER JOIN UserProfile on UserProfile.UserID = Users.UserId

 WHERE  Roles.PortalId = [DNN:PortalId]
  AND    (EffectiveDate <= getdate() or EffectiveDate is null)  
  AND (Roles.RoleName like '%MyRole%')
  AND Users.UserId = [DNN:UserId]
  AND UserProfile.PropertyDefinitionID IN (SELECT UserProfile.PropertyDefinitionID FROM UserProfile WHERE UserProfile.PropertyDefinitionID=40 or UserProfile.PropertyDefinitionID=39)
 
  As you might see it is the PropertyValues from PropertyDefinitionsID 39 and 40 i need.

Now what do i do wrong here?!?

 
New Post
11/26/2007 3:35 PM
 

Try using embedded queries rather than JOINs:

SELECT Roles.RoleName as Subscription, UserRoles.ExpiryDate as Expires, (SELECT PropertyValue FROM UserProfile WHERE UserProfile.UserId = @UserId AND UserProfile.PropertyDefinitionID = 39) as Server, (SELECT PropertyValue FROM UserProfile WHERE UserProfile.UserId = @UserId AND UserProfile.PropertyDefinitionID = 40) as Administration
FROM Users
INNER JOIN UserRoles ON UserRoles.UserId = Users.UserId
INNER JOIN Roles ON UserRoles.RoleId = Roles.RoleID
WHERE ... as before but WITHOUT the final AND clause ...

Also, the '[]' tokens should not be working with the Reports module, they expose the module to a SQL Injection attack because they use String concatenation. The Module provides the @PortalID, @ModuleID, @TabID, @UserID parameters to allow you to access current information (you can use these to get almost all the info you need, and we will be providing more options in a future version)


Andrew Nurse
DotNetNuke Core Team Member and Reports Module Project Lead
Microsoft Certified Professional Developer

 
New Post
1/19/2008 3:42 PM
 

Ty m8, this work perfect.

The reson for [ ] was because i ws using the SQLView for DNN, but with the new Report, ill switch back.

Anoring oart is i missed your answer back in november, but ty anyway

 
New Post
1/24/2008 2:59 PM
 

No problem, glad that fixed your problem!


Andrew Nurse
DotNetNuke Core Team Member and Reports Module Project Lead
Microsoft Certified Professional Developer

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsSQL HELP!SQL HELP!


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