SqlTransaction 已完成;它再也无法使用。
try{apc.sqlOpen();trans=apc.conn.BeginTransaction();comm=apc.conn.CreateCommand();com...
try
{
apc.sqlOpen();
trans = apc.conn.BeginTransaction();
comm = apc.conn.CreateCommand();
comm.Transaction = trans;
comm.Connection = apc.conn;
comm.CommandText = "update tb_users set Balance = " + (dbSource - (Double.Parse(txtMoney.Text))) + " where CarDID = '" + atmPubClass.strCard + "'";
comm.ExecuteNonQuery();
comm.CommandText = "update tb_users set Balance = " + (dbObject + (Double.Parse(txtMoney.Text))) + " where CarDID = '" + txtMuBiao.Text + "'";
comm.ExecuteNonQuery();
comm.CommandText = "insert tb_transfer (SourceCardID , TargetCardID , Cash ,Balance ,Time) values ('" + atmPubClass.strCard + "','" + txtMuBiao.Text + "'," + txtMoney.Text + "," + (dbSource - (Double.Parse(txtMoney.Text))) + ",getDate())";
comm.ExecuteNonQuery();
trans.Commit();
if (MessageBox.Show(this, "转账操作已经成功执行,是否打印凭条", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
String stid = "select max(TradeID) as tid from tb_transfer where CardID = '" + atmPubClass.strCard + "'";
SqlCommand cmd = new SqlCommand(stid, apc.conn);
SqlDataReader cdr = cmd.ExecuteReader();
this.Hide();
frm_zhuanReport fzp = new frm_zhuanReport(cdr["tid"].ToString());
fzp.ShowDialog();
}
else
{
this.Hide();
frm_main fm = new frm_main();
fm.ShowDialog();
}
}
}
catch (Exception ex)
{
trans.Rollback();
MessageBox.Show(ex.Message);
}
finally
{
apc.sqlClose();
}
您说的我都已经试过了。
trans.dispose(), trans = null ,关闭conn 再打开。都试过了。 展开
{
apc.sqlOpen();
trans = apc.conn.BeginTransaction();
comm = apc.conn.CreateCommand();
comm.Transaction = trans;
comm.Connection = apc.conn;
comm.CommandText = "update tb_users set Balance = " + (dbSource - (Double.Parse(txtMoney.Text))) + " where CarDID = '" + atmPubClass.strCard + "'";
comm.ExecuteNonQuery();
comm.CommandText = "update tb_users set Balance = " + (dbObject + (Double.Parse(txtMoney.Text))) + " where CarDID = '" + txtMuBiao.Text + "'";
comm.ExecuteNonQuery();
comm.CommandText = "insert tb_transfer (SourceCardID , TargetCardID , Cash ,Balance ,Time) values ('" + atmPubClass.strCard + "','" + txtMuBiao.Text + "'," + txtMoney.Text + "," + (dbSource - (Double.Parse(txtMoney.Text))) + ",getDate())";
comm.ExecuteNonQuery();
trans.Commit();
if (MessageBox.Show(this, "转账操作已经成功执行,是否打印凭条", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
String stid = "select max(TradeID) as tid from tb_transfer where CardID = '" + atmPubClass.strCard + "'";
SqlCommand cmd = new SqlCommand(stid, apc.conn);
SqlDataReader cdr = cmd.ExecuteReader();
this.Hide();
frm_zhuanReport fzp = new frm_zhuanReport(cdr["tid"].ToString());
fzp.ShowDialog();
}
else
{
this.Hide();
frm_main fm = new frm_main();
fm.ShowDialog();
}
}
}
catch (Exception ex)
{
trans.Rollback();
MessageBox.Show(ex.Message);
}
finally
{
apc.sqlClose();
}
您说的我都已经试过了。
trans.dispose(), trans = null ,关闭conn 再打开。都试过了。 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询