列数与第1行的值计数不匹配

列数与第1行的值计数不匹配

问题描述:

使用mysql db在c#.net中进行插入查询的代码:

code for the insert query in c#.net with mysql db:

private void btnsave_Click(object sender, EventArgs e)
      {
         string test = "@name,@age,@sex,@refby,@refno,@date,@hemoglobin,@rbc_count,@pcv,@mcv,@mch,@mchc,@rdw,@total_wbc_count,@polymorphs,@lymphocyts,@monocytes,@eosinophils,@Basophils,@Normoblasts,@Lymphoblasts,@Prolymphocytes,@Myeloblasts,@Promyeloblasts,@Myelocytes,@Metamyelocytes,@BandCells,@esr,@Plateletcount,@plateletsmear1,@PlateletSmearFg,@Bloodgroup,@rh,@AEC,@ReticCount,@Sicklingtest_Metabisulphite,@Sicklingtest_dithionite,@FetalHb,@HbA2,@mp1,@ThickThinSmear,@ThickThinSmearFg,@ps_rbcseries,@ps_rbcseriesfg,@ps_wbcseries,@ps_wbcseriesfg,@ps_platelet,@CoombsTest_Direct,@CoombsTest_Indirect,@remarks,@remarksfg,@timeofcollection,@correctedtc,@ESR2hr,@MPQBC,@MPMethod,@Morpho1,@Density1,@Morpho2,@Density2,@Morpho3,@Density3,@Morpho4,@Density4,@Morpho5,@Density5,@Densitynm,@BT,@CT,@Anisocytosis,@Hypochromia,@Microcytosis,@Macrocytosis,@Poikilocytosis,@Polychromesia,@TargetCell,@TearCell,@SickleCell,@PRNFLG,@New1,@New2,@New3,@CorrectedRetic,@Sno,@HBF,@bondtransfusion,@History,@ElectroComments,@ElectroCommentsfg,@RapidCard,@ReportExam,@BloodMp,@blood,@Pfalci,@FalciR,@Pvivex,@PVR,@BYstd,@wbcgraph,@pltgraph,@rbcgraph,@prgid,@ps";
          string[] field = test.Split(',');
          int size = field.Length;
          Control[] formcontrol = new Control[103] { txtname, txtage, txtage, txtref, txtaccno, dtp1, txtheamo, txtrcbcount, txtpcv, txtmcv, txtmch, txtmchc, txtrdw, txtwbc, txtpolymorphs, txtlymp, txtmono, txteosi, txtbaso, txtNormoblasts, txtLymphoblasts, txtProlymphocytes, txtMyeloblasts, txtPromyeloblasts, txtMyelocytes, txtMetamyelocytes, txtband, txtesr, txtplate, txtblank, txtblank, cbbloodgrp, cbrh, txtaec, txtretic, cbsicking1, cbsicking2, txtfetal, txthba, txtthick, txtthick, txtplateletsmearfg, txtrbcseries, txtrbcfg, txtwbc, txtwbcfg, txtplateletson, cbdirect, cbindirect, txtremarks, txtremarkfg, dtptime, txtCorrectedTLC, txtesr2, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtbt, txtct, txtAnisocytosis, txtHypochromia, txtMicrocytosis, txtMacrocytosis, txtPoikilocytosis, txtPolychromesia, txtTargetCell, txtTearCell, txtSickleCell, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank, txtblank };
       str = "INSERT INTO cbc_new(name,age,sex,refby,refno,date,hemoglobin,rbc_count,pcv,mcv,mch,mchc,rdw,total_wbc_count,polymorphs,lymphocyts,monocytes,eosinophils,Basophils,Normoblasts,Lymphoblasts,Prolymphocytes,Myeloblasts,Promyeloblasts,Myelocytes,Metamyelocytes,BandCells,esr,Plateletcount,plateletsmear1,PlateletSmearFg,Bloodgroup,rh,AEC,ReticCount,Sicklingtest_Metabisulphite,Sicklingtest_dithionite,FetalHb,HbA2,mp1,ThickThinSmear,ThickThinSmearFg,ps_rbcseries,ps_rbcseriesfg,ps_wbcseries,ps_wbcseriesfg,ps_platelet,CoombsTest_Direct,CoombsTest_Indirect,remarks,remarksfg,timeofcollection,Heading,correctedtc,ESR2hr,MPQBC,MPMethod,Morpho1,Density1,Morpho2,Density2,Morpho3,Density3,Morpho4,Density4,Morpho5,Density5,Densitynm,BT,Btnm,CT,Ctnm,esr2hrnm,Anisocytosis,Hypochromia,Microcytosis,Macrocytosis,Poikilocytosis,Polychromesia,TargetCell,TearCell,SickleCell,PRNFLG,New1,New2,New3,CorrectedRetic,Sno,HBF,bondtransfusion,History,ElectroComments,ElectroCommentsfg,RapidCard,ReportExam,BloodMp,blood,Pfalci,FalciR,Pvivex,PVR,BYstd,wbcgraph,pltgraph,rbcgraph,prgid,ps) VALUES(@name,@age,@sex,@refby,@refno,@date,@hemoglobin,@rbc_count,@pcv,@mcv,@mch,@mchc,@rdw,@total_wbc_count,@polymorphs,@lymphocyts,@monocytes,@eosinophils,@Basophils,@Normoblasts,@Lymphoblasts,@Prolymphocytes,@Myeloblasts,@Promyeloblasts,@Myelocytes,@Metamyelocytes,@BandCells,@esr,@Plateletcount,@plateletsmear1,@PlateletSmearFg,@Bloodgroup,@rh,@AEC,@ReticCount,@Sicklingtest_Metabisulphite,@Sicklingtest_dithionite,@FetalHb,@HbA2,@mp1,@ThickThinSmear,@ThickThinSmearFg,@ps_rbcseries,@ps_rbcseriesfg,@ps_wbcseries,@ps_wbcseriesfg,@ps_platelet,@CoombsTest_Direct,@CoombsTest_Indirect,@remarks,@remarksfg,@timeofcollection,@correctedtc,@ESR2hr,@MPQBC,@MPMethod,@Morpho1,@Density1,@Morpho2,@Density2,@Morpho3,@Density3,@Morpho4,@Density4,@Morpho5,@Density5,@Densitynm,@BT,@CT,@Anisocytosis,@Hypochromia,@Microcytosis,@Macrocytosis,@Poikilocytosis,@Polychromesia,@TargetCell,@TearCell,@SickleCell,@PRNFLG,@New1,@New2,@New3,@CorrectedRetic,@Sno,@HBF,@bondtransfusion,@History,@ElectroComments,@ElectroCommentsfg,@RapidCard,@ReportExam,@BloodMp,@blood,@Pfalci,@FalciR,@Pvivex,@PVR,@BYstd,@wbcgraph,@pltgraph,@rbcgraph,@prgid,@ps)";
          cmd = new MySqlCommand(str, Classmysql.conmain);
          int i = 0;
          foreach (string w in field)
          {
              cmd.Parameters.AddWithValue(w.Trim(), formcontrol[i].Text);

              i++;
          }
          cmd.ExecuteNonQuery();
          MessageBox.Show("saved");
     }



错误详情:


error details:

MySql.Data.MySqlClient.MySqlException was unhandled
  Message="Column count doesn't match value count at row 1"
  Source="MySql.Data"
  ErrorCode=-2147467259
  Number=1136



请帮忙解决这个问题紧急。

提前谢谢。


please help to resolve this problem its urgent.
thanks in advance.

检查你的号码。田野和没有。价值观字段和值都应相等。
Check your no. of fields and no. of values. Both fields and values should be equal.


缺少将参数传递给



标题 - > @Heding







这是在这里:Heading,correcttc,ESR2hr,MPQBC,

你错过了这个
you are missing to pass the parameter to

Heading->@Heding



this is at here: "Heading",correctedtc,ESR2hr,MPQBC,
you are missing this one


你好首先你必须正确检查你的查询....



Btnm,这些值的CT,Ctnm,esr2hrnm不是传递参数
hello first you must check your query properly....

Btnm,CT,Ctnm,esr2hrnm for these values you are not pass parameters