CsharpHome  
protected void Button1_Click(object sender, EventArgs e)
        {
            string connString =@"server=localhost\SQLEXPRESS;database=FSYCurtainSalesMISDB;uid=sa;pwd=123";
            SqlConnection sqlConn = new SqlConnection(connString );
            string strSql  ="select count(*) from member where uname=@name and pwd=@pass";
            SqlCommand cmd = new SqlCommand(strSql, sqlConn);
            sqlConn.Open();
            cmd.Parameters.Add(new SqlParameter("name", SqlDbType.VarChar, 10));
            cmd.Parameters["name"].Value = TextBox1.Text;
            cmd.Parameters.Add(new SqlParameter("pass", SqlDbType.VarChar, 10));
            cmd.Parameters["pass"].Value = TextBox2.Text;

            if (Convert.ToInt32(  cmd.ExecuteScalar())>0)
            {
                string caValue = Convert.ToString(Cache[TextBox1.Text]);
                if (caValue == string.Empty)
                {
                    TimeSpan sessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);
                    HttpContext.Current.Cache.Insert(TextBox1.Text, TextBox2.Text, null, DateTime.MaxValue, sessTimeOut, CacheItemPriority.NotRemovable, null);
                    Session["name"] = TextBox1.Text;
                    Response.Write("cg");
                }
                else
                { 
                    Response.Write("ydl");
                }
            }
            else 
            {
              Response.Write ("sb");
            }
        }
posted on 2010-12-03 09:08  CsharpHome  阅读(178)  评论(0)    收藏  举报