我有一个包含以下代码的登录页面:
程序:
ALTER PROCEDURE [dbo].[Login_Validation]
@email varchar(100),
@password varchar(50)
AS
BEGIN
DECLARE @cnt INTEGER
SET @cnt = (SELECT COUNT(*) FROM SUBSCRIBER_MASTER WHERE EmailId=@email AND [Password]=@password AND [Status]='Y')
END
类文件:
public void Login_Validation(string email, string password)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);
try
{
LocalConnection_Class(con);
SqlCommand cmd = new SqlCommand("Login_Validation", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@email", SqlDbType.VarChar, 100)).Value = email;
cmd.Parameters.Add(new SqlParameter("@password", SqlDbType.VarChar, 50)).Value = password;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
}
cmd.Dispose();
con.Close();
}
catch (Exception)
{ }
}
cs 文件:
protected void btnSubmit_Click(object sender, EventArgs e)
{
string login = obj.Login_Validation(txtEmail.Text, txtPassword.Text);
}
我无法理解如何解决该错误。有人可以帮我吗?它给了我一个错误:“无法在 obj.Login_Validation 处将 void 隐式转换为字符串”。