为什么数据会自动清除?
public bool InsertInfo(string NOID, DataSet ds, string dyno, string ck, DateTime dt, string fx, string czy){
bool result = false;
OleDbConnection Ocon = new OleDbConnection(connection);
Ocon.Open();
using (OleDbTransaction Otran = Ocon.BeginTransaction())
{
using (OleDbCommand Ocmd = Ocon.CreateCommand())
{
Ocmd.Transaction = Otran;
try
{
for (int i = 0; i < ds.Tables["Info"].Rows.Count; i++)
{
int tm_xh = i + 1;
string tm = ds.Tables["Info"].Rows[i]["tm"].ToString();
decimal lrsl = Convert.ToDecimal(ds.Tables["Info"].Rows[i]["sl"].ToString());
string zdr = "扫描枪";
string cw = "cw";
string wlbm = ds.Tables["Info"].Rows[i]["wlbm"].ToString();
string xp = ds.Tables["Info"].Rows[i]["xp"].ToString();
Ocmd.CommandText = @"insert into tm (""TM_NO"",""TM_XH"",""TM"",""CK"",""DYNO"",""LRSL"",""ZDR"",""ZDRQ"",""SFKD"",""CW"",""WLBM"",""XP"",""FX"",""CZY"") values ('" + NOID + "'," + tm_xh + ",'" + tm + "','" + ck + "','" + dyno + "'," + lrsl + ",'" + zdr + "',sysdate,'N','" + cw + "','" + wlbm + "','" + xp + "'," + fx + ",'" + czy + "')";
Ocmd.ExecuteNonQuery();
}
Otran.Commit();
result = true;
}
catch (Exception ex)
{
Otran.Rollback();
throw ex;
}
finally
{
if (Ocon.State != ConnectionState.Closed)
Ocon.Close();
Ocon.Dispose();
}
} }
return result;
}
在提交数据时网络断开了,然后提示 提交失败 ,但表中的数据也自动清除了,为什么? --------------------编程问答-------------------- Rollback,回滚
补充:.NET技术 , C#