Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I wrote a simple c# code that connect to sql-server database and execute a query:

C#
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 <b1>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

try this :

SQL
REVOKE SELECT ON OBJECT::user1.myTB FROM user2
 
Share this answer
 
Comments
Mohamad77 28-Feb-13 2:48am    
thanks, but it doesn't work.
Thanks friends,
I've solved it and use DENY instead of REVOKE :

DENY select ON user1.myTB TO user2
 
Share this answer
 

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