日期:2014-05-18  浏览次数:20965 次

BatchInsert
public static object[] BatchInsert(OracleTransaction trans, string cmdString, OracleParameter[][] Params, string sqlGetNewKey)
{
  OracleCommand command = new OracleCommand(cmdString, trans.Connection, trans);
  command.Prepare();
  object[] objArray = new object[Params.Length];
  int num = 0;
  foreach (OracleParameter[] parameterArray in Params)
  {
  foreach (OracleParameter parameter in parameterArray)
  {
  command.Parameters.Add(parameter);
  }
  command.ExecuteNonQuery();
  objArray[num++] = ExecuteScalar(trans, sqlGetNewKey, null);
  }
  return objArray;
}

 

 


------解决方案--------------------
这段代码是将新值存入数据库,然后查询新值并赋给数组objArray[],返回新值即返回刚插入数据库的值