Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have a table in which a have different column name after web pages of my site,and a user ID column,i want to check which column has true or false value against this user ,and on the base of this i want to give access to this user to see my web pages.how i can do this using c#,
Posted
Comments
PIEBALDconsult 28-Aug-14 16:07pm    
It's simple enough. Where are you stuck?
Sajid227 28-Aug-14 16:28pm    
problem 1 is .admin of site does not has developing knowledge,he wants to give user access by just putting 1 or zero against each page title which i have created in the table of Page access with user role_id,that is requirement by admin.plz adjust it with the web that this can b e implemented,
i think after log in user will check his status from this table,and if there are 1 or 2 page access is granted using 1 or zero by admin then on front end in menu link only these form must be display.
Sergey Alexandrovich Kryukov 28-Aug-14 17:31pm    
You are not answering the very reasonable question asked above.
Short answer is: use ADO.NET. Any problems with that?
—SA
Sajid227 28-Aug-14 18:02pm    
im not figer out where to start it, and how handle this problem,i'm totally blank
[no name] 28-Aug-14 19:22pm    
You still have not described any kind of a problem. Start by learning C# or VB.NET, ADO.NET and SQL. Then connect to your database, query the data out of your database and then use the data.

OK - so as I read it, each column name is the name of a web page, with the exception of the primary key which is a user Id

So

You select the row 'where Id = current user.id'

Now you have a record set of some sort (may be a table object, or a DataReader or a POCO , depending on how you do your data access)

So - at its most simple, create a function that returns a boolean

C#
private DataRow theDataRowWithThePageNamesInItForThisUser;
bool CanThisUserAccessThisPage(string pageName)
{
    return (bool)theDataRowWithTheOageNamesInItForThisUser[pageName];
}


(that's just splatted-in pseudo-code PLEASE don't just copy-paste it and assume it's going to work on your system - if you can't figure out how to do something with this then I'd advise you to stand clear of the keyboard!
 
Share this answer
 
You haven't stated what database server you're using, but in general they don't have a Boolean datatype.
So you will have to save it as a Number(1,0) instead (Bit if it's SQLServer). Set 0 as false and 1 as true, and convert it to Boolean in your business layer.
 
Share this answer
 
Comments
Sajid227 29-Aug-14 14:20pm    
i'm using sql server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900