--用户验证存储
create proc proc_Login(@userName varchar(50),@passWord varchar(50))
as
begin
select * from dbo.UserInfo where [email protected] and[email protected]
end
--调用存储
exec pro_login 'chenyun','123'
--在ASP中调用存储
//执行存储过程
SqlConnection con = new SqlConnection("Data Source=ZHOUYAPENG;Initial Catalog=chenyun;Integrated Security=True");
con.Open();
var cmd = new SqlCommand("proc_Login", con);
cmd.CommandType = CommandType.StoredProcedure;
//添加输入查询参数、赋予值
cmd.Parameters.Add("@userName", SqlDbType.VarChar);
cmd.Parameters["@userName"].Value = name;
cmd.Parameters.Add("@passWord",SqlDbType.VarChar);
cmd.Parameters["@passWord"].Value = pwd;
//执行查询
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
MessageBox.Show("成功!");
else
MessageBox.Show("失败!");
}