使用ADO.NET的只读查询 [英] Read only queries Using ADO.NET

查看:142
本文介绍了使用ADO.NET的只读查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将应用程序限制为只读查询。换句话说,我希望应用程序仅处理那些不会更改数据库状态的查询。我正在使用ADO.NET。我不想针对具有只读权限的数据库创建新用户。欢迎任何建议。

I want to limit the application to read only queries. In other words, I want the application to process only those queries which are not changing the state of the database. I am using ADO.NET. I do not want to create a new user against the database with read only permissions. Any suggestions are welcome.

推荐答案

选项1:SQL身份验证

您可以使用如下所示的连接:

You can use connections as shown below:

Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};

使用仅在数据库中具有读取权限的uid。

Use the uid which has only read access in database.

选项2:Windows身份验证

如果要使用 Integrated Security = True; (即Windows身份验证),那么您将必须授予Windows用户(程序将在其下运行)的只读访问权限。

If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).

希望这会有所帮助。

这篇关于使用ADO.NET的只读查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆