asp.net做登陆页面(用sql数据库)的全部代码
1个回答
展开全部
public static void Checkname(string name,string pwd,string returnUrl)
{
SqlConnection conn=new SqlConnection(ConnStr);
conn.Open();
SqlCommand comm=new SqlCommand("select * from [User] where uname=@name and pwd=@password",conn);
comm.Parameters.Add("@name",SqlDbType.NVarChar).Value=name;
comm.Parameters.Add("@password",SqlDbType.NVarChar).Value=pwd;
SqlDataReader sdr=comm.ExecuteReader();
if(sdr.Read())
{
Response.Write("登陆成功");
}
else
{
Response.Write("登陆失败");
}
comm.Dispose();
conn.Close();
}
public static string ConnStr
{
get
{
NameValueCollection configSettings=(NameValueCollection)ConfigurationSettings.GetConfig("WebSettings");
return configSettings["ConnStr"];
}
}
{
SqlConnection conn=new SqlConnection(ConnStr);
conn.Open();
SqlCommand comm=new SqlCommand("select * from [User] where uname=@name and pwd=@password",conn);
comm.Parameters.Add("@name",SqlDbType.NVarChar).Value=name;
comm.Parameters.Add("@password",SqlDbType.NVarChar).Value=pwd;
SqlDataReader sdr=comm.ExecuteReader();
if(sdr.Read())
{
Response.Write("登陆成功");
}
else
{
Response.Write("登陆失败");
}
comm.Dispose();
conn.Close();
}
public static string ConnStr
{
get
{
NameValueCollection configSettings=(NameValueCollection)ConfigurationSettings.GetConfig("WebSettings");
return configSettings["ConnStr"];
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询