一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

ASP.NET简单整理收藏(1)

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

 
//连接数据库:



//登录
string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];
SqlConnection conn=new SqlConnection(connstr);
conn.Open();
string sql="select count(*) as icount from sysoper where logname='"+this.usrname.Text+"'";
SqlCommand comm=new SqlCommand(sql,conn);
SqlDataReader dr1=comm.ExecuteReader();
dr1.Read();
string count=dr1["icount"].ToString();
dr1.Close();
if(count!="0")
{
 sql="select * from sys where logname='"+this.usrname.Text+"'";
 SqlCommand  comm1=new SqlCommand(sql,conn);
 SqlDataReader dr=comm1.ExecuteReader();
 dr.Read();
 string drpwd=dr["logpass"].ToString();
 dr.Close();
 if(drpwd==this.usrpwd.Text)
 {
    this.Session["logid"]=this.usrname.Text.Trim();
    if(dr["PLCName"].ToString()=="")
    {
     this.Session["level"]="1";
    }
    if(dr["PLCName"].ToString()!="")
    {
     this.Session["level"]="2";
     this.Session["plcname"]=dr["PLCName"].ToString();
    } 
    this.Response.Redirect("main.aspx");
 }

热门栏目