这是我的代码:
SqlParameter rolename = new SqlParameter("rolename", SqlDbType.VarChar);
rolename.Direction = ParameterDirection.Input;
rolename.Value = "role";
SqlParameter password = new SqlParameter("password", SqlDbType.VarChar);
password.Direction = ParameterDirection.Input;
password.Value = "123@123";
SqlParameter fCreateCookie = new SqlParameter("fCreateCookie", SqlDbType.Bit);
fCreateCookie.Direction = ParameterDirection.Input;
fCreateCookie.Size = 100;
fCreateCookie.Value = true;
SqlParameter cookie = new SqlParameter("cookie", SqlDbType.VarBinary);
cookie.Direction = ParameterDirection.Output;
cookie.Size = 8000;
_context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "EXEC sp_setapprole @rolename,@password,@fCreateCookie, @cookie OUT;", rolename, password, fCreateCookie, cookie);
我得到一个错误:
形式参数" @ fCreateCookie"未被声明为OUTPUT参数,但是在请求的输出中传递了实际参数。
有人能告诉我我做错了吗?
答案 0 :(得分:0)
您缺少参数
ALTER procedure [sys].[sp_setapprole]
@rolename sysname, -- name app role
@password sysname, -- password for app role
--> @encrypt varchar(10) = 'none', -- Encryption style ('none' | 'odbc')
@fCreateCookie bit = 0,
@cookie varbinary(8000) = 0xFFFFFFFF OUTPUT
as
你需要添加一个参数者@encrypt =' none'在executeccommand调用
之前的@fcreatecookie之前