static OracleConnection OpenConn()
string connstr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***.***.***.***)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=***)));Persist Security Info=True;User ID=***;Password=***;";
OracleConnection conn = new OracleConnection();
conn.ConnectionString = connstr;
public bool insert(string tableName, IList list, int length)
string sql = "INSERT INTO " + tableName + "(XH,MMSI,UTC,LAT,LON,SOG,COG,UDATE) values(SEQ_SHIPPOINT.Nextval,:MMSI,:UTC,:LAT,:LON,:SOG,:COG,:UDATE)";
using (OracleConnection conn = OpenConn())
int recordCount = list.Count;
using (OracleCommand cmd = conn.CreateCommand())
cmd.ArrayBindCount = recordCount;
cmd.Parameters.Add(new OracleParameter(":MMSI", OracleDbType.Varchar2, ParameterDirection.Input)).Value = list.Select(x => x.mmsi).ToArray();
cmd.Parameters.Add(new OracleParameter(":UTC", OracleDbType.Long, ParameterDirection.Input)).Value = list.Select(x => x.utc).ToArray();
cmd.Parameters.Add(new OracleParameter(":LAT", OracleDbType.Long, ParameterDirection.Input)).Value = list.Select(x => x.lat).ToArray();
cmd.Parameters.Add(new OracleParameter(":LON", OracleDbType.Long, ParameterDirection.Input)).Value = list.Select(x => x.lon).ToArray();
cmd.Parameters.Add(new OracleParameter(":SOG", OracleDbType.Long, ParameterDirection.Input)).Value = list.Select(x => x.sog).ToArray();
cmd.Parameters.Add(new OracleParameter(":COG", OracleDbType.Long, ParameterDirection.Input)).Value = list.Select(x => x.cog).ToArray();
cmd.Parameters.Add(new OracleParameter(":UDATE", OracleDbType.Date, ParameterDirection.Input)).Value = list.Select(x => x.udate).ToArray();
returnrow = cmd.ExecuteNonQuery();