Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I wrote a simple c# code that connect to sql-server database and execute a query:
 
            cmd = new SqlCommand(txtQuery.Text.ToString().Trim(), con);
            cmd.ExecuteNonQuery();
 
- 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.
thanks.
Posted 27-Feb-13 2:45am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this :
 
REVOKE SELECT ON OBJECT::user1.myTB FROM user2
  Permalink  
Comments
Mohamad77 at 28-Feb-13 2:48am
   
thanks, but it doesn't work.
Rate this: bad
good
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
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 1 Mar 2013
Copyright © CodeProject, 1999-2014
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