开发者

Ado.Net ExecuteReader with a read-only SQL Server user

开发者 https://www.devze.com 2023-01-24 04:47 出处:网络
At the Application_Start of my web site I execute a stored procedure to read some data from one SQL Server 2008 database.

At the Application_Start of my web site I execute a stored procedure to read some data from one SQL Server 2008 database.

This is the only call to this database.

I would create a specific SQL Server user开发者_StackOverflow, with read-only permission, to exec this sp.

I created a new SQL Server user with db_datareader role, but when I exec the sp I have an error at this line:

SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

The error is: EXECUTE permission denied on object ...

How can I workaround this ?

Thanks


Have you granted the user you created access to the stored procedure?

GRANT EXECUTE ON sp_your_proc TO your_user;
0

精彩评论

暂无评论...
验证码 换一张
取 消