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);
//}