title: Bulk data insert from SQL to Oracle using C#.NET
body: <p>The following code snippet  for for bulk insert of data from SQL DB into Oracle database.</p>
  
  <p>I have used stored procedure in oracle database with 2 parameters (int and string)</p>
  
  <p>I am getting the below error while executing the query. Please help me to resolve this. or suggest any good solution for bulk data insert.</p>
  
  <p>My Query:</p>
  
  <pre><code>List&lt;int&gt; arrPersonId = new List&lt;int&gt;();
  
          foreach (DataRow row in ds.Tables[0].Rows)
          {
              arrPersonId.Add(Convert.ToInt32(row["USER_ID"]));
  
          }
  
          List&lt;string&gt; arrPersonName = new List&lt;string&gt;();
  
          foreach (DataRow row in ds.Tables[0].Rows)
          {
              arrPersonName.Add(row["USERNAME"].ToString());
          }
  
          OracleConnection connection = new OracleConnection();
          connection.ConnectionString = DAKObj.GetOraConnectionString();
  
          OracleCommand command = new OracleCommand();
          command.Connection = connection;
  
          command.CommandType = CommandType.StoredProcedure;
          command.CommandText = "sp_InsertByODPNET";
  
          command.Parameters.Add("@PersonId", OracleDbType.Int32);
          command.Parameters[0].Value = arrPersonId;
          command.Parameters.Add("@PersonName", OracleDbType.Varchar2, 100);
          command.Parameters[1].Value = arrPersonName;
         command.ArrayBindCount = arrPersonId.Count;
  
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
  </code></pre>
  
  <h2><strong>Error</strong>:-</h2>
  
  <blockquote>
    <p>An exception of type 'System.InvalidCastException' occurred in
    Oracle.DataAccess.dll but was not handled in user code</p>
    
    <p>Additional information: Unable to cast object of type
    'System.Collections.Generic.List`1[System.Int32]' to type
    'System.Array'</p>
  </blockquote>