473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

aspnet_Roles and aspnet_usersinroles

I have a complex query which doesn't return what I need using outer joins.

The query i've tried is:

SELECT dbo.User_Roles_Views.UserId, dbo.Roles_view.RoleName
FROM dbo.User_Roles_Views RIGHT OUTER JOIN
dbo.Roles_view ON dbo.User_Roles_Views.RoleName = dbo.Roles_view.RoleName
WHERE (dbo.User_Roles_Views.UserId = 'e69f320b-f1da-480e-9c54-9fa0680299d6')

WHat I am trying to return is the Roles in which the user belongs to and the roles in which he doesn't (Null Rows).

Role UserID
Admin e69f320b-f1da-480e-9c54-9fa0680299d6
Guest NULL
OUtput e69f320b-f1da-480e-9c54-9fa0680299d6
Status null

You get the idea!

I can then use this to populate a checkboxlist and do stuff with it. I could just call the aspnet_roles in the checkboxlist then iterate through the items and set checked state by using the data - but that would be too easy.
Jan 24 '08 #1
2 2712
deepuv04
227 Expert 100+
I have a complex query which doesn't return what I need using outer joins.

The query i've tried is:

SELECT dbo.User_Roles_Views.UserId, dbo.Roles_view.RoleName
FROM dbo.User_Roles_Views RIGHT OUTER JOIN
dbo.Roles_view ON dbo.User_Roles_Views.RoleName = dbo.Roles_view.RoleName
WHERE (dbo.User_Roles_Views.UserId = 'e69f320b-f1da-480e-9c54-9fa0680299d6')

WHat I am trying to return is the Roles in which the user belongs to and the roles in which he doesn't (Null Rows).

Role UserID
Admin e69f320b-f1da-480e-9c54-9fa0680299d6
Guest NULL
OUtput e69f320b-f1da-480e-9c54-9fa0680299d6
Status null

You get the idea!

I can then use this to populate a checkboxlist and do stuff with it. I could just call the aspnet_roles in the checkboxlist then iterate through the items and set checked state by using the data - but that would be too easy.
probably this will help

SELECT v1.UserId, rv.RoleName
FROM dbo.Roles_view as RV LEFT OUTER JOIN
(SELECT UserId,RoleName FROM dbo.User_Roles_Views
WHERE UserId = 'e69f320b-f1da-480e-9c54-9fa0680299d6' ) AS v1 ON
RV.RoleName = V1.RoleName
Jan 24 '08 #2
Cheers for the reply - Although it doesn't do exactly what I want but I went with

SELECT
a.itemname,
b.userid,
CONVERT(bit, CASE WHEN USERID IS NULL THEN 0 ELSE 1 END) AS Item
FROM
dbo.cbx_Item_1 AS a LEFT OUTER JOIN dbo.cbx_user_items AS b ON a.itemname = b.itemName
AND
b.userid = @userid


Cheers
Jan 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: AC | last post by:
Hi there. My asp.net 2.0 development website uses roles to control access to sections of my site, configured using the asp.net configuration tool, which is great. Except that isn't available once...
1
by: Ruth413 | last post by:
Hello - I am getting the these errors in my sql 2005 generated script. I am stuck with first error. Please help.... Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. Msg 319,...
4
by: JJ | last post by:
How can I import my current asp.net membership records in my local sql server to the empty tables on the live server? I've tried removing contraints with: ALTER TABLE aspnet_Applications...
1
by: ascll | last post by:
Greetings, How do I use SQL script to insert record into aspnet_Roles? The and are solely depend on machine, but we cannot insert NULL value. Any idea? thanks
0
by: ArvisLT | last post by:
Hi, I'm trying to make SQL query which selects data dependent on current ASP user and his being in user groups. I have tables: AspNet_Users – contains UserName and UserID columns AspNet_Roles –...
1
by: =?Utf-8?B?aGZkZXY=?= | last post by:
Hello, I have a web application that makes use of the SQL Membership and Role providers. My app has admin screens to manage users (membership), roles, and supplementary user data. I have just...
5
by: Jonathan Wood | last post by:
Greetings, I'm using ASP.NET membership and I'd like to query the number of users in a particular role. I don't want the overhead of returning a dataset and then getting the number of items...
1
by: =?Utf-8?B?ZVByaW50?= | last post by:
Asp.Net v2.0 I have created a web application and I am using it from a single website and database. The web application has different ‘portals’ – each independent and I am using the...
2
by: Bart | last post by:
Hi, i made a select which fetches the value of a UniqueIdentifier field (aspnet_Roles.RoleId ) my questions are: 1) variable 'myrole' must be defined as what? 2) myrole=dtreader.Get?? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.