Solved

Data transfer from SQL Server to Oracle database

Posted on 2010-09-09
4
516 Views
Last Modified: 2012-05-10
Hi,
Can someone provide me with the advice\or post url what is the best way to transfer data
from SQL Server to Oracle database using VB.NET.
I have instaled Oracle Client 11.x which supports OracleBulkCopy but for some reason I face with the problem when i try to write data to server . The error is as follows:
"ORA-01738 missing IN keyword".
It breaks in line "copy.WriteToServer(dt)".
Now, since I could not resolve my problem I am trying to workarround the same and find different solution if possibe (even solution for the current problem where OracleBulkCopy is used would be great )
By the way I have two same tables I try to move date both on SQL Server and Oracle side.
Thank you...


(see vb code below)
Public Sub Retrieve_Records()
        Dim conn1 As New SqlConnection(My.Settings.MyCon)
        conn1.Open()

        Dim cmd1 As New System.Data.SqlClient.SqlCommand()
        cmd1.Connection = conn1
        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = "select partija, sektor, saldo from IFRS_partije"
        cmd1.Parameters.Add("@datum_val", SqlDbType.NVarChar)
        cmd1.Parameters("@datum_val").Value = Me.DateTimePicker1.Value.ToString("yyyy.mm.dd")
        cmd1.CommandTimeout = 0
        Dim rdr As SqlDataReader = cmd1.ExecuteReader
        Dim dt As New DataTable("IFRS_partije")
        dt.Load(rdr)
        rdr.Close()
        conn1.Close()

        Using cn As New OracleConnection(connectStr)
            cn.Open()
            Dim cmd As New OracleCommand
            cmd.Connection = cn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "DELETE FROM POMOCNA_IFRS_NOVA"
            cmd.ExecuteNonQuery()

            Using copy As New OracleBulkCopy(connectStr)
                copy.DestinationTableName = "POMOCNA_IFRS_NOVA"
                copy.WriteToServer(dt)
            End Using
        End Using
        MessageBox.Show("Successfully inserted on Oracle!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
    End Sub

Open in new window

0
Comment
Question by:alsam
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33643171
When moving data between two different data sources, I prefer to use SSIS to do that job.  If you don't understand SSIS, there would be a learning curve involved.  That syntax error doesn't make an sense.  
0
 
LVL 1

Author Comment

by:alsam
ID: 33644281
thank you for your reply...
I have no exiprience with SSIS but definitelly I will go in deep after I searched the web about this topic.
Can I ask you what did you mean by telling that syntax error does not make any sense?
Do you see any "unlogic" in my vb code....For some reason I can not find out why this error message is returned....Have you ever before move data from SQL Server to Oracle using bulkcopy ... do you have any useful advice for me how maybe to solve the problem....
Anyway Thank you for your time and effort
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 33646613
The "IN" keyword is usually for something like this:

SELECT * FROM Production.Product WHERE ProductID IN (1, 2, 3, 4)

I don't see how that relates to the work that the OracleBulkCopy would need to do.
0
 
LVL 1

Author Closing Comment

by:alsam
ID: 33700065
Ok,
I have make this working prefectly.... I had problem with grants in oracle db....
Thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 Publish Error 2 34
Help with preventing downloading a zip file 10 45
RLDC Reporting in Visual studio 11 30
Access Schema 6 25
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question