ASP.NET设计网站
OleDbCommandins_com=newOleDbCommand();OleDbTransactiontrans=conn.BeginTransaction();s...
OleDbCommand ins_com = new OleDbCommand();
OleDbTransaction trans = conn.BeginTransaction();
string ins_str = "";
if (TextBox1.Text == "" || TextBox4.Text == "" || TextBox3.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox9.Text == "")
{
showmessage("注册操作:所有信息均不能为空!");
return;
}
// DropDownList1.Text = "";
if (addored == "0")
{
ins_str = "insert into Puser values('";
ins_str+= TextBox1.Text + "','" + TextBox4.Text + "','" + DropDownList1.SelectedValue.ToString() + "','";
ins_str+= TextBox3.Text + "',0,'" + DateTime.Now.ToString() +"','" + TextBox5.Text + "','" + TextBox6.Text + "','";
ins_str+= TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + RadioButtonList1.SelectedValue.ToString() + "',0";
}
if (addored == "1")
{
ins_str = "update Puser set Pname='" + TextBox4.Text + "',";
ins_str+= "Ptype='" + DropDownList1.SelectedValue.ToString() + "',Pcode='" + TextBox5.Text + "',";
ins_str+= "Padd='" + TextBox6.Text + "',Pph='" + TextBox7.Text + "',Pemail='" + TextBox8.Text + "',Pid='" + TextBox9.Text + "',";
ins_str+= "Psex+'" + RadioButtonList1.SelectedValue.ToString() + "'where id='" + TextBox1.Text + "'";
}
ins_com.Connection = conn;
ins_com.CommandText = ins_str;
ins_com.Transaction = trans;
try
{
ins_com.ExecuteNonQuery();
Label14.ForeColor = System.Drawing.Color.Yellow;
Label14.Text = "注册操作:成功!";
showmessage("注册操作:成功!");
trans.Commit();
}
catch
{
Label14.ForeColor = System.Drawing.Color.Red;
Label14.Text = "注册操作:失败!";
showmessage("注册操作:失败!");
trans.Rollback();
}
finally
{
conn.Close();
}
运行后一直是输出失败,求大神赐解 展开
OleDbTransaction trans = conn.BeginTransaction();
string ins_str = "";
if (TextBox1.Text == "" || TextBox4.Text == "" || TextBox3.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox9.Text == "")
{
showmessage("注册操作:所有信息均不能为空!");
return;
}
// DropDownList1.Text = "";
if (addored == "0")
{
ins_str = "insert into Puser values('";
ins_str+= TextBox1.Text + "','" + TextBox4.Text + "','" + DropDownList1.SelectedValue.ToString() + "','";
ins_str+= TextBox3.Text + "',0,'" + DateTime.Now.ToString() +"','" + TextBox5.Text + "','" + TextBox6.Text + "','";
ins_str+= TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + RadioButtonList1.SelectedValue.ToString() + "',0";
}
if (addored == "1")
{
ins_str = "update Puser set Pname='" + TextBox4.Text + "',";
ins_str+= "Ptype='" + DropDownList1.SelectedValue.ToString() + "',Pcode='" + TextBox5.Text + "',";
ins_str+= "Padd='" + TextBox6.Text + "',Pph='" + TextBox7.Text + "',Pemail='" + TextBox8.Text + "',Pid='" + TextBox9.Text + "',";
ins_str+= "Psex+'" + RadioButtonList1.SelectedValue.ToString() + "'where id='" + TextBox1.Text + "'";
}
ins_com.Connection = conn;
ins_com.CommandText = ins_str;
ins_com.Transaction = trans;
try
{
ins_com.ExecuteNonQuery();
Label14.ForeColor = System.Drawing.Color.Yellow;
Label14.Text = "注册操作:成功!";
showmessage("注册操作:成功!");
trans.Commit();
}
catch
{
Label14.ForeColor = System.Drawing.Color.Red;
Label14.Text = "注册操作:失败!";
showmessage("注册操作:失败!");
trans.Rollback();
}
finally
{
conn.Close();
}
运行后一直是输出失败,求大神赐解 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询