HI我正在收到「併發違反updatecommand影響0期望1記錄。」嘗試更新一行時發生錯誤,奇怪的是我可以單次更新該行,並且下一次我在同一行上重複該過程時出現錯誤,我已經嘗試了endinit並結束了其中的任務將不勝感激!第二次更新行的併發錯誤C#
我使用C#和MySQL的InnoDB
string cs = "server=" + fidaConfig.dtBDConfig.Rows[0][2] + ";user id=root;Password=" + fidaConfig.dtBDConfig.Rows[0][4] + ";persist security info=True;database=facturas";
MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection() { ConnectionString = cs };
switch (tableInvoice)
{
case "factura_idj":
dsLuiscencioTableAdapters.factura_idjTableAdapter idjAdapter = new Control_Administrativo.dsLuiscencioTableAdapters.factura_idjTableAdapter() { Connection = conn };
dsLuiscencio.factura_idjDataTable idj = idjAdapter.GetData();
var facturaidj = (from f in idj where f.no_factura_idj == InvoiceNumber select f).Single();
if (DateTime.Today.Date >= Convert.ToDateTime("01-01-2010") && facturaidj.fecha.Date <= Convert.ToDateTime("01-01-2010"))
{
var quieresactualizar = MessageBox.Show("Desea Actualizar el total de acuerdo a los nuevos impuestos?", "Reforma Fiscal", MessageBoxButtons.YesNo);
if (quieresactualizar == DialogResult.Yes)
{
switch (facturaidj.opt_iva)
{
case 1:
facturaidj.iva = 0;
facturaidj.total = facturaidj.subtotal;
break;
case 2:
facturaidj.iva = facturaidj.subtotal * 0.11;
facturaidj.total = facturaidj.subtotal * 1.11;
break;
case 3:
facturaidj.iva = facturaidj.subtotal * 0.16;
facturaidj.total = facturaidj.subtotal * 1.16;
break;
default:
break;
}
Number2Letter.Number2Letter n2l = new Number2Letter.Number2Letter();
string totalwithnocents = n2l.Numero2Letra(facturaidj.total.ToString(), 0, 0, "peso", "",
Number2Letter.Number2Letter.eSexo.Masculino,
Number2Letter.Number2Letter.eSexo.Masculino).ToUpper();
string strtotalconivaretenido = Math.Round(facturaidj.total, 2, MidpointRounding.ToEven).ToString("###########.00");
string cents = strtotalconivaretenido.Substring(strtotalconivaretenido.IndexOf(".") + 1);
facturaidj.total_letra = string.Format(@"{0} {1}/100 {2}", totalwithnocents, cents, facturaidj.tipo_moneda).ToUpper();
idj.EndInit();
idjAdapter.Update(facturaidj);//this runs only the first time on a row, then throws the error
}
}
break;
continues......
請發送代碼 – CSharpAtl 2010-01-05 01:21:36
您使用的是MyISAM還是InnoDB? – CSharpAtl 2010-01-05 01:23:43
在您的表適配器更新後是否有更新行?像觸發器一樣? – mlsteeves 2010-01-05 01:33:20