我有一个存储过程如下:
ALTER PROCEDURE [dbo].[sp_CheckEmailAvailability] -- Add the
parameters for the stored procedure here ( @Email VARCHAR(50)=null,
@Count int OUTPUT
) AS BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements. SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @Count=COUNT(*) from dbo.tx_UserPersonalDetails where s_Email=@Email
END
我的 aspx.cs 页面中有以下代码:-
SqlCommand cmd = new SqlCommand("[dbo].[sp_CheckEmailAvailability]", objcon);
int result = 0;
try
{
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter parm = new SqlParameter("@Email", SqlDbType.VarChar);
parm.Value = txtUserName.Text.ToString();
parm.Direction = ParameterDirection.Input;
cmd.Parameters.Add(parm);
SqlParameter parm1 = new SqlParameter("@Count", SqlDbType.Int);
// parm1.Value = txtUserName.Text.ToString();
parm.Direction = ParameterDirection.Output;
cmd.Parameters.Add(parm1);
cmd.Connection.Open();
result=cmd.ExecuteNonQuery();
if (result>0)
{
lblAvailText.Text = "Email id is in use";
}
else
{
lblAvailText.Text = "Email id is Available";
}
}
catch (SqlException sql)
{
}
finally
{
cmd.Connection.Close();
}
当我运行代码时,我收到一个错误:-
形式参数“@Email”未声明为 OUTPUT 参数,而是在请求的输出中传递的实际参数。
请帮帮我。