加了以后最后的SQL语句跟踪出来是这样的:
insert into Ccme_Form_Allot(CFA_BaseId,CFA_ColumnId,CFA_Row,CFA_Col,CFA_Type,CFA_Obiect,CFA_Attrib,CFA_IsNull) values(10000069,10000053,1,1,'10','10','10','0');\r\n insert into Ccme_Form_Allot(CFA_BaseId,CFA_ColumnId,CFA_Row,CFA_Col,CFA_Type,CFA_Obiect,CFA_Attrib,CFA_IsNull) values(10000069,10000054,1,2,'10','10','10','0');\r\n insert into Ccme_Form_Allot(CFA_BaseId,CFA_ColumnId,CFA_Row,CFA_Col,CFA_Type,CFA_Obiect,CFA_Attrib,CFA_IsNull) values(10000069,10000055,2,1,'10','10','10','0');\r\n 然后就报错了

解决方案 »

  1.   

    程序改成
    for(i=0;i<Str_Arr.Length;i++)
    {
    Str_Sql = Str_Sql + Str_Arr[i].ToString() + ";\r\n ";
    }以后就出现了上面的情况
      

  2.   

    实在不行,改为这样的sql语句,一个 insert into 搞定
    insert into temp(a,b) select '1','2' union all select '1','2' union all select  '1','2'
      

  3.   

    说白了我就是想将两条语句一起来执行。用分号相隔放在应用程序的command对象里来执行
      

  4.   

    加分号加换行,总之不要把 \n\r 传给 DBMS 就行了,DBMS可不认识 \n\r 或是 \r\n
    问题在这。你看看程序传给 DBMS 的SQL字符串就明白了。楼主试一下,放一个richedit,把生成的str_sql放在里面,再把里面的sql执行,那样就没有 \n\r了。
      

  5.   

    sorry,应该是 textBox也可以。
      

  6.   

    public static void ExecComplexSQL(System.Data.OracleClient.OracleConnection  oracleConn,string[] oracleQuery)
    {
    try
    {
    OracleCommand oracleCmd = new OracleCommand();
    OracleTransaction oracleTrans = null;
    try
    {
    oracleConn.Open();
    oracleTrans = oracleConn.BeginTransaction(IsolationLevel.Serializable );
    oracleCmd.Connection = oracleConn;
    oracleCmd.CommandType = CommandType.Text;
    oracleCmd.Transaction = oracleTrans;
    for (int i=0;i<oracleQuery.Length;i++)
    {
    oracleCmd.CommandText = oracleQuery[i];
    oracleCmd.ExecuteNonQuery();
    }
    oracleTrans.Commit();
    oracleTrans.Dispose();
    oracleConn.Close();
    oracleCmd.Dispose();
    oracleTrans = null;
    oracleCmd = null;
    oracleConn = null;

    }
    catch(Exception ex)
    {
    if(oracleTrans != null)
    oracleTrans.Rollback();
    try
    {
    oracleTrans.Dispose();
    oracleTrans = null;
    }
    catch
    {
    oracleTrans = null;
    }
    try
    {
    oracleConn.Close();
    oracleConn = null;
    }
    catch
    {
    oracleConn = null;
    }
    try
    {
    oracleCmd.Dispose();
    oracleCmd = null;
    }
    catch
    {
    oracleCmd = null;
    }

    throw ex;
    }
    }
    catch(Exception ex)
    {
    throw ex;
    }
    }
      

  7.   

    非常感谢 xiaxilin(扑向小狼的羊) ,按照你的方法,已经成功解决了问题。结帖