///// <summary> ///// 以現有表格數據批量添加數據 ///// </summary> ///// <param name="dt">數據表格</param> ///// <param name="FormName">數據表名</param> ///// <param name="DBUrl">數據庫鏈接地址</param> ///// <returns></returns> //public bool AddInBatchesToDataTable(DataTable dt, string FormName, string DBUrl) //{ // try // { // if (FormName.ToString().Trim() == "") throw new Exception("數據表名不能为空"); // System.Diagnostics.Debug.WriteLine("----------------------開始執行--------------------------"); // System.Diagnostics.Debug.WriteLine("執行表明:" + dt.TableName + "--------------------------"); // long star = Convert.ToInt64(System.DateTime.Now.ToString("yyyyMMddHHmmssfff")); // Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection(DBUrl); // OracleBulkCopy bulkCopy = new OracleBulkCopy(DBUrl, OracleBulkCopyOptions.UseInternalTransaction); // bulkCopy.BatchSize = 100000; // bulkCopy.BulkCopyTimeout = 260; // bulkCopy.DestinationTableName = FormName; //服务器上目标表的名称 // bulkCopy.BatchSize = dt.Rows.Count; //每一批次中的行数 // try // { // conn.Open(); // if (dt != null && dt.Rows.Count != 0) // bulkCopy.WriteToServer(dt); //将提供的数据源中的所有行复制到目标表中 // } // catch (Exception ex) // { // throw ex; // } // finally // { // conn.Close(); // if (bulkCopy != null) // bulkCopy.Close(); // } // long end = Convert.ToInt64(System.DateTime.Now.ToString("yyyyMMddHHmmssfff")); // System.Diagnostics.Debug.WriteLine("共添加:" + dt.Rows.Count + "條數數據----耗時:" + ((end - star) / 10000) + "." + ((end - star) % 10000) + "秒"); // System.Diagnostics.Debug.WriteLine("----------------------執行結束--------------------------"); // return true; // } // catch (Exception ex) // { // throw ex; // } //} /// <summary> /// 將輸入參數的類型與Oracle中的參數類型轉化一致 /// </summary> /// <param name="propertyInfo">屬性特征</param> /// <param name="obj">對象</param> /// <returns></returns> private Oracle.ManagedDataAccess.Client.OracleDbType GetOracleDbType(PropertyInfo propertyInfo, object obj) { try { Oracle.ManagedDataAccess.Client.OracleDbType oracleDbType = new Oracle.ManagedDataAccess.Client.OracleDbType(); switch (propertyInfo.GetValue(obj, null).GetType().Name) { case "String": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.NVarchar2; break; case "Int32": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Int32; break; case "Int64": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Int64; break; case "DateTime": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Date; break; case "Blob": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Blob; break; case "Double": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Double; break; case "Decimal": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Decimal; break; case "Long": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Long; break; case "Boolean": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.Boolean; break; case "BinaryFloat": oracleDbType = Oracle.ManagedDataAccess.Client.OracleDbType.BinaryFloat; break; } return(oracleDbType); } catch (Exception ex) { throw ex; } }
void GetOracleDbType(Database._OracleDbType pOracleDbType, ref Oracle.ManagedDataAccess.Client.OracleDbType pDAOracleDbType) { if (pOracleDbType == _OracleDbType.OraByte) { pDAOracleDbType = OracleDbType.Byte; } else if (pOracleDbType == _OracleDbType.OraBlob) { pDAOracleDbType = OracleDbType.Blob; } else if (pOracleDbType == _OracleDbType.OraDate) { pDAOracleDbType = OracleDbType.Date; } else if (pOracleDbType == _OracleDbType.OraDecimal) { pDAOracleDbType = OracleDbType.Decimal; } else if (pOracleDbType == _OracleDbType.OraDouble) { pDAOracleDbType = OracleDbType.Double; } else if (pOracleDbType == _OracleDbType.OraInt16) { pDAOracleDbType = OracleDbType.Int16; } else if (pOracleDbType == _OracleDbType.OraInt32) { pDAOracleDbType = OracleDbType.Int32; } else if (pOracleDbType == _OracleDbType.OraInt64) { pDAOracleDbType = OracleDbType.Int64; } else if (pOracleDbType == _OracleDbType.OraLong) { pDAOracleDbType = OracleDbType.Long; } else if (pOracleDbType == _OracleDbType.OraSingle) { pDAOracleDbType = OracleDbType.Single; } else if (pOracleDbType == _OracleDbType.OraVarchar2) { pDAOracleDbType = OracleDbType.Varchar2; } }