bnde是实例化Entity, proc_LogOn是登陆的存储过程
bnsde.proc_LogOn(username, HashPassword, ”这里会显示要输入第三个参数,应该输入什么?“);
存储过程如下:
ALTER PROCEDURE [dbo].[proc_LogOn]
-- Add the parameters for the stored procedure here
@username varchar(50),
@password varchar(50),
@result bit output -- 如果结果不为0则登录成功,否则登录失败
AS
if exists(select * from users where username=@username and password=@password)
begin
set @result = 1 -- 登录成功
end
else
begin
set @result = 0 -- 登录失败
end
求解~
只要照着下面代码中的para3改为你的result1/2就可以了。
using (SEntities se = new SEntities())
{
EntityConnection entityConnection = (EntityConnection)se.Connection;
DbConnection storeConnection = entityConnection.StoreConnection;
storeConnection.Open();
DbCommand command = storeConnection.CreateCommand();
command.CommandText = "NameOfStoredProcedure";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("param1", value_of_param1));
command.Parameters.Add(new SqlParameter("param2", value_of_param2));
SqlParameter param3 = new SqlParameter();
pA.SqlDbType = SqlDbType.Bit;
pA.ParameterName = "@param3";
pA.Direction = ParameterDirection.Output;
command.Parameters.Add(param3);
command.ExecuteNonQuery();
returnValue = Convert.ToBoolean(param3.Value);
}