Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
I wrote a simple c# code that connect to sql-server database and execute a query:
            cmd = new SqlCommand(txtQuery.Text.ToString().Trim(), con);
- in my db I have a table named myTB. I have two users too: user1(owner), user2(new user created)
- I logged in (connected to DB) with user2's username and password !
- I can access the tables that created by user1 by the query bellow:
"select * from user1.myTB"
(I don't know why I get error with this query:"select * from myTB", forget it now!)
- Now I wanna REVOKE 'select' permission from user2. I mean I don't want user2 to execute the select query on myTB table which is created by user1.
- what should I do is a problem that I'm stuck on it !
I used this query, but nothing changed !
Q1: "Revoke select ON user1.myTB FROM user2"
again user2 can do select * from user1.myTB !!! WHY !?
please help me with this.
Posted 27-Feb-13 2:45am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this :
Mohamad77 at 28-Feb-13 2:48am
thanks, but it doesn't work.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thanks friends,
I've solved it and use DENY instead of REVOKE :
DENY select ON user1.myTB TO user2

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

  Print Answers RSS
0 OriginalGriff 476
1 Sergey Alexandrovich Kryukov 235
2 CHill60 195
3 Afzaal Ahmad Zeeshan 145
4 TheRealSteveJudge 120
0 Sergey Alexandrovich Kryukov 9,121
1 OriginalGriff 7,920
2 Peter Leow 4,774
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,176

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 1 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100