protected SqlConnection Conn;
protected string ConnectionString = "server=.; database=ExpatiateAspNet; uid=sa; pwd=";
protected void Page_Load(object sender, EventArgs e)
{
using (Conn = new SqlConnection(ConnectionString))
{
Conn.Open();//打开数据库连接
SqlCommand cmd = new SqlCommand("Proc_UserLogin", Conn);
cmd.CommandType = CommandType.StoredProcedure;//调用存储过程
cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50).Value = "mr";
cmd.Parameters.Add("@UserPwd", SqlDbType.VarChar, 50).Value = "mrsoft";
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{
Response.Write("登录成功!");
}
}
}