无限的向数据库写入数据.这是怎么回事???.
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);
//}
{
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);
//}
相关文章推荐
- 使用FMDatabase,插入数据到数据库时,报错无法写入只读数据库文件,要怎么办?
- 将excel的数据导入到数据库后都乱码了是怎么回事
- 怎么在VS2008中创建数据库和数据表
- 面试常见问题--数据库优化 百万数据怎么优化
- 统计各个数据库的各个数据表的总数,然后写入到excel中
- DataTable数据批量写入数据库三种方法比较 以及方法介绍
- Jxl将Excel中的数据写入数据库--->现成code
- 通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
- 把服务器端数据库的DATASET数据写入客户端EXCEL文件
- .Net读取Excle数据写入到数据库
- xml 数据 写入 数据库 转帖
- php管理后台内容写入数据库,前台数据读取于数据库
- 在数据库中存储层次数据实现无限级分层
- 要通过Echarts把数据可视化,前台与后台以及数据库怎么搭建?
- 怎么在后台将数据库中数据查询出来并分页显示在客户端?!!!
- 使用Apache POI创建Excel,并从数据库中读取数据写入到Excel文件中
- 从数据库中读取数据并写入到Excle电子表格之2
- 怎么把xml文件中的数据读出,并保存到数据库中
- 由JDBC事务引起的锁状态以及内存数据无法写入数据库的问题