您的位置:首页 > 数据库

无限的向数据库写入数据.这是怎么回事???.

2007-04-19 23:24 246 查看
  protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox2.Text == "")
        {
            this.Label1.Text = "为什么不把你的大名留下呢?";
            return;
        }
        else if (this.TextBox1.Text == "")
        {
            this.Label2.Text = "你难道没有话对我说吗?";
            return;
        }
        else
        {
            SqlConnection conn = DB.createCon();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            if (gg == "aboutme")
            {
                cmd.CommandText = "INSERT liuyan VALUES('"+ this.TextBox2.Text  +"','" + this.TextBox1.Text + "','" + "gg" + "')";
            }
            if (gg == "showV")
            {
                cmd.CommandText = "INSERT Vliuyan VALUES('" + this.Vid + "','" + this.TextBox2.Text + "','" + this.TextBox1.Text +"','" + "KK" + "')";
            }
            try
            {
                conn.Open();
            }
            catch
            {
                Server.Transfer("temp.aspx", true);
            }
            cmd.ExecuteReader();
            cmd.Dispose();
            conn.Close();
            this.TextBox1.Text = "";
            this.TextBox2.Text = "";

            //为什么加入下面的代码会使页面无限的向数据库写入数据???
            //if (gg == "aboutme")
            //{
            //   Server.Transfer("aboutme.aspx", true);

            //}
            //if (gg == "showV")
            //{
            //   Server.Transfer("showV.aspx", true);
            //}
        }
    }

     //为什么加入下面的代码会使页面无限的向数据库写入数据???
            //if (gg == "aboutme")
            //{
            //   Server.Transfer("aboutme.aspx", true);

            //}
            //if (gg == "showV")
            //{
            //   Server.Transfer("showV.aspx", true);
            //}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐