我以前做过,但无法让它工作,我只想在我的 SP 中进行选择,返回任何内容,然后在代码隐藏中执行,然后对返回的代码执行任何操作。
C# 代码
protected long getPassword(string EnteredPass)
{
var connectionString = ConfigurationManager.ConnectionStrings["GetConnector"].ConnectionString;
SqlConnection dbConnection = new SqlConnection();
dbConnection.ConnectionString = connectionString;
SqlCommand dbCommand = new SqlCommand("PL_User_Check", dbConnection);
dbCommand.CommandType = CommandType.StoredProcedure;
SqlParameter abc = dbCommand.Parameters.Add("@User", SqlDbType.VarChar);
abc.Value = EnteredPass;
dbCommand.Parameters.Add("@ReturnValue", SqlDbType.Int, 4).Direction = ParameterDirection.ReturnValue;
dbConnection.Open();
dbCommand.ExecuteNonQuery();
dbConnection.Close();
object x = dbCommand.Parameters[""].Value;
return Convert.ToInt64(x);
}
存储过程...
ALTER PROCEDURE [dbo].[PL_User_Check]
@User VARCHAR(50),
@ReturnValue BIGINT OUTPUT
AS
DECLARE @pass BIGINT
--Data
SET @Pass = (SELECT Pass
FROM dbo.UserPasswords
WHERE [User] = @User)
SET @ReturnValue = @Pass