Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:20:53+00:00 2026-05-27T00:20:53+00:00

I am using C# ASP.NET on Visual Studio 2005, as well as SQL Server

  • 0

I am using C# ASP.NET on Visual Studio 2005, as well as SQL Server 2005.

Currently I have a project which requires me to check each user for any conflicting roles that they might posses.

I have 2 database. Users and ConflictingRoles. Below is the structure of the 2 tables:

enter image description hereenter image description here

In Users, I have 2 unique users with 4 roles each.

In ConflictingRoles, I have 4 rows of conflicing roles.

James and Jennifer each have 4 roles, and each of them is conflicting with one another.

I want to form multiple SQL queries, to check each role possessed by each user if they are in conflict with any other role which they posses.

I have a rough idea of how the process will be like, but I am not sure how to portray the idea using multiple SQL queries:


1) One row at a time, grep the value usr.UserID and usr.Role from Users usr table.

Store usr.UserID in to temporary variable tempUID, and find matching vales of usr.Role with cf.Role in ConflictingRoles cf table.

2) If usr.Role matches cf.Role, grep the value of cf.ConflictingRole and run through all usr.Role in Users table WHEREusr.UserID matches tempUID.

If a match/conflict is found between cf.ConflictingRole with usr.Role of user tempUID, insert cf.ConflictingRole, usr.Role and user.Name into a separate table, Results.

3) Repeat this for all roles that each user posses, and for all users.


Basically is that a user is not allowed to posses both roles which are conflicting each other. If they do, store the name, role and conflictingrole in a table.


It is very confusing for me and I am not sure if there is a simplier way to do it.

If not, I will like to request help from you guys with the SQL queries that I will have to form with my above logical sequence.

SqlConnection thisConnection = new SqlConnection("Data Source=DS");
SqlCommand nonqueryCommand = thisConnection.CreateCommand();
thisConnection.Open();

      //multiple sql commands
      nonqueryCommand.CommandText = "<SQL Query>";
      Console.WriteLine(nonqueryCommand.ExecuteNonQuery());

      ...

Thank you for any help in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:20:54+00:00Added an answer on May 27, 2026 at 12:20 am

    First approach:

    Insert into results(userID, role, conflictingRole)
    Select distinct
         U.UserId, U.role, C.conflictionRole
    FROM
         users U 
       inner join  --join role with all conflicted roles
         conflictingRoles C
           on U.role = C.role
    WHERE
         --chech if user has conflicted role
         exists (
            select * 
            from Users U2
            where  U2.userId = U.userId and
                   U2.role = C.conflictionRole
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting a project with asp.net visual studio 2008 / SQL 2000 (2005
I am using ASP.NET MVC2 in Visual Studio 2008. I believe the SQL Server
I am using ASP.NET MVC2 in Visual Studio 2008. I believe the SQL Server
I am new to visual studio/asp.net so please bear with me. Using vs 2005
Using asp.net 3.5 Gridview control, visual studio 2008. I have played with all the
I'm using Visual Studio 2008 to develop ASP.NET applications. Currently I'm debugging with running
I am using visual studio 2008 coding asp.net.vb I have 20 images on my
strong text i am using asp.net in visual studio 2005 how can i put
While developing and ASP.NET application in C# or VB using Visual Studio 2005/2008/2010 (Not
Project being built on ASP.net v 2 VB.net IIS 6 SQL Server 2005 database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.