Click here to Skip to main content
13,002,133 members (76,741 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 <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.
Posted 27-Feb-13 1:45am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this :

Mohamad77 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
Top Experts
Last 24hrsThis month

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