Click here to Skip to main content
11,713,845 members (85,251 online)
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 1: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 Sergey Alexandrovich Kryukov 370
1 CHill60 250
2 Maciej Los 229
3 Richard MacCutchan 210
4 OriginalGriff 175
0 Sergey Alexandrovich Kryukov 365
1 CHill60 335
2 OriginalGriff 245
3 Andy Lanng 173
4 Richard MacCutchan 150

Advertise | Privacy | Mobile
Web02 | 2.8.150819.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