1. 程式人生 > >資料庫應用程式角色配置

資料庫應用程式角色配置

alter application role [myapprole] with name=[denlu], password='234567', DEFAULT_SCHEMA = [dbo]
3、配置解色許可權
在角色可操作的表中滑鼠選擇表點右建屬性=》許可權
在開啟的窗體搜尋角色,點搜尋出來使用者和角色的搜尋窗,物件型別選擇應用角色,點選下方的瀏覽選擇角色如“denlu”
選擇確定以後在屬性窗裡使用者和角色欄裡就多了一個"denlu"角色,選擇角色在它對應的下方許可權設定許可權,配置就完成了
4、使用
例:C#
    public class getconnection
    {
        private System.Data.SqlClient.SqlConnection mypunconnection;
        public getconnection(string csstring, string awe, string olk)
        {
            System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(csstring);
            System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("sp_setapprole", connection);
            try
            {
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Clear();
                command.Parameters.Add("@rolename", System.Data.SqlDbType.NVarChar).Value = awe;
                command.Parameters.Add("@password", System.Data.SqlDbType.NVarChar).Value = olk;
                connection.Open();
                command.ExecuteNonQuery();
                this.mypunconnection = connection;