473,396 Members | 1,892 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,396 software developers and data experts.

SQL syntax question

ASP.NET 2.0.....

How do I get all users (in aspnet_Users) that are not in the "member" role
(aspnet_Roles)?

Thanks.
Feb 3 '06 #1
4 1133
Hi ???

Try this?

Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
ShowRoleData()
End If
End Sub
Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
GridView1.DataSource = Roles.GetUsersInRole _
("members")
GridView1.DataBind()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Role Info</title>
<style type="text/css">
body, span, label { font-size:large}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</div>
</form>
</body>
</html>

"VB Programmer" <do**@emailme.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
ASP.NET 2.0.....

How do I get all users (in aspnet_Users) that are not in the "member" role
(aspnet_Roles)?

Thanks.

Feb 4 '06 #2
Thanks. But, how do I get those NOT in role "members"?

And... it's Robert. ;)

Thanks again Ken!

"Ken Cox - Microsoft MVP" <BA**********@hotmail.com> wrote in message
news:eC****************@tk2msftngp13.phx.gbl...
Hi ???

Try this?

Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
ShowRoleData()
End If
End Sub
Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
GridView1.DataSource = Roles.GetUsersInRole _
("members")
GridView1.DataBind()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Role Info</title>
<style type="text/css">
body, span, label { font-size:large}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</div>
</form>
</body>
</html>

"VB Programmer" <do**@emailme.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
ASP.NET 2.0.....

How do I get all users (in aspnet_Users) that are not in the "member"
role (aspnet_Roles)?

Thanks.


Feb 4 '06 #3
Hey Robert,

Sorry about that read it too fast. It looks like there's no built-in method
for that so it takes a little hack. This just loops through all the users,
checks them against the role and adds the non members to a datatable.

Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
Dim memb As MembershipUser
Dim dt As New Data.DataTable
Dim dc As New Data.DataColumn
dc.ColumnName = "user"
dc.DataType = GetType(System.String)
dt.Columns.Add(dc)
For Each memb In Membership.GetAllUsers
If Not Roles.IsUserInRole(memb.UserName, "members") Then
dt.Rows.Add(memb.UserName)
End If
Next
GridView1.DataSource = dt
GridView1.DataBind()
End Sub

Does that work for you?

Ken
Microsoft MVP [ASP.NET]
"VB Programmer" <do**@emailme.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...
Thanks. But, how do I get those NOT in role "members"?

And... it's Robert. ;)

Thanks again Ken!

"Ken Cox - Microsoft MVP" <BA**********@hotmail.com> wrote in message
news:eC****************@tk2msftngp13.phx.gbl...
Hi ???

Try this?

Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
ShowRoleData()
End If
End Sub
Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
GridView1.DataSource = Roles.GetUsersInRole _
("members")
GridView1.DataBind()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Role Info</title>
<style type="text/css">
body, span, label { font-size:large}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</div>
</form>
</body>
</html>

"VB Programmer" <do**@emailme.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
ASP.NET 2.0.....

How do I get all users (in aspnet_Users) that are not in the "member"
role (aspnet_Roles)?

Thanks.



Feb 4 '06 #4
I think it will Ken. Thanks!

"Ken Cox - Microsoft MVP" <BA**********@hotmail.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Hey Robert,

Sorry about that read it too fast. It looks like there's no built-in
method for that so it takes a little hack. This just loops through all the
users, checks them against the role and adds the non members to a
datatable.

Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
Dim memb As MembershipUser
Dim dt As New Data.DataTable
Dim dc As New Data.DataColumn
dc.ColumnName = "user"
dc.DataType = GetType(System.String)
dt.Columns.Add(dc)
For Each memb In Membership.GetAllUsers
If Not Roles.IsUserInRole(memb.UserName, "members") Then
dt.Rows.Add(memb.UserName)
End If
Next
GridView1.DataSource = dt
GridView1.DataBind()
End Sub

Does that work for you?

Ken
Microsoft MVP [ASP.NET]
"VB Programmer" <do**@emailme.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...
Thanks. But, how do I get those NOT in role "members"?

And... it's Robert. ;)

Thanks again Ken!

"Ken Cox - Microsoft MVP" <BA**********@hotmail.com> wrote in message
news:eC****************@tk2msftngp13.phx.gbl...
Hi ???

Try this?

Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
ShowRoleData()
End If
End Sub
Protected Sub ShowRoleData()
Dim Provider As SqlProfileProvider
Dim pageIndex As Integer = 0
Dim pageSize As Integer = 100
Provider = Profile.Providers _
("AspNetSqlProfileProvider")
GridView1.DataSource = Roles.GetUsersInRole _
("members")
GridView1.DataBind()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Role Info</title>
<style type="text/css">
body, span, label { font-size:large}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</div>
</form>
</body>
</html>

"VB Programmer" <do**@emailme.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
ASP.NET 2.0.....

How do I get all users (in aspnet_Users) that are not in the "member"
role (aspnet_Roles)?

Thanks.



Feb 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Aaron Walker | last post by:
Greetings, I'm attempting to write my first *real* template function that also deals with a map of strings to member function pointers that is making the syntax a little tricky to get right. ...
2
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
3
by: astromog | last post by:
I have some significantly extended syntax for Python that I need to create a reference implementation for. My new syntax includes new keywords, statements and objects that are sort of like classes...
11
by: deppy_3 | last post by:
Hi! The syntax of fputs() is similar with the syntax of fgets(); For example if we have:fgets(str,maxlen,stdin) which is the syntax of the fputs();
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
2
by: berrylthird | last post by:
This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example: var myInstance:myClass = new...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
6
by: Daniel | last post by:
I hope this question is OK for this list. I've downloaded Rpyc and placed it in my site packages dir. On some machines it works fine, on others not so much. Here is one error I get when I try...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.