title: How Transform OracleAdapter Dataset to SQL BulkCopy
body: <p>I've successfully used the <code>Oracle.ManagedDataAccess.Client</code> to fetch data from an Oracle server into a <code>Dataset</code>, and used <code>SqlBulkCopy</code> to insert  that <code>Dataset</code> into a SQL database where the tables have matching columns names (see below).</p>
  
  <p>How would I go about manipulating the <code>Insert</code> of the <code>Dataset</code> so I can specify where the columns in the <code>Dataset</code> would go into the SQL table, allowing me to use non-identical tables?</p>
  
  <p>E.g. <code>SourceTable(column1)</code> Inserts to <code>DestinationTable(column4)</code></p>
  
  <p>I was thinking this may be able to be achieved with a SQL Insert statement like:</p>
  
  <p><code>INSERT INTO DestinationTable ([column4]) Values ([column1])</code></p>
  
  <p>But I don't know how to manipulate the <code>Dataset</code> into my SQL statement. My code <em>so far</em>:</p>
  
  <pre><code>    Dim i As Double = 1
      Dim j As Double = 5000
  
      Dim Oconn As New OracleConnection(connectionString &amp; mySource)
  
      Oconn.Open()
  
      Dim Osqlstr As String = "Select column1, " _
                                  &amp; "column2, " _
                                  &amp; "column3, " _
                                  &amp; "column4, " _
                                  &amp; "from " _
                                  &amp; "(Select rownum r, " _
                                  &amp; "column1, " _
                                  &amp; "column2, " _
                                  &amp; "column3, " _
                                  &amp; "column4, " _
                                  &amp; "from mysourcetable)" _
                                  &amp; "where rownum &gt;=" &amp; i &amp; " and rownum &lt;=" &amp; j _
                                  &amp; " order by column1 asc"
  
      Dim Ocommand As New OracleCommand(Osqlstr, Oconn)
      Dim Oda As New OracleDataAdapter(Ocommand)
      Dim Ods As New DataSet()
  
      Oda.Fill(Ods)
  
      Using myBulk As New SqlBulkCopy(DB_COMMS)
  
          myBulk.DestinationTableName = "mydestinationtable"
          Try
              myBulk.WriteToServer(Ods.Tables(0))
          Catch ex As Exception
              MsgBox("Error:- " &amp; ex.Message)
          End Try
  
      End Using
  
      Ods.Dispose()
  
      Oconn.Close()
  </code></pre>