Simix48
Simix48

Reputation: 55

oracle connection into c# ssis script task

I have a connection manager that points to an oracle database.I then need to use that said connection into a ssis script task.I don't know how to proceed.I tried something and I got an error message could you help me.Here is my code: I also tried with those connection string:

// SqlConnection conn = new SqlConnection("Data Source=SOURCE;User ID=user_GG;Provider=OraOLEDB.Oracle.1;Persist Security Info=True;");
SqlConnection oracleConn = new SqlConnection("Data Source=PRONMPIA;Persist Security Info=True;Integrated Security=yes;");
oracleConn.Open();

using (SqlCommand command = new SqlCommand("SELECT count(*) FROM random.table", oracleConn))
using (SqlDataReader reader = command.ExecuteReader())
{
    while (reader.Read())
    {
        int name = reader.GetInt32(0);
        MessageBox.Show("SALUT " + name.ToString() );
    }
}
oracleConn.Close();

MessageBox.Show(" test succes");
Dts.TaskResult = (int)ScriptResults.Success;

Upvotes: 1

Views: 4555

Answers (1)

Laszlo
Laszlo

Reputation: 31

You are trying to use SqlConnection which is a .Net component for SQL Server, not for Oracle. You need the Oracle.DataAccess.Client and the OracleConnection. To use that you need to add the Oracle .Net provider to the References of the Script task (see project explorer References node when editing the script task .Net code), Add Oracle.DataAccess, then in you code "using Oracle.DataAccess.Client;". HTH

Upvotes: 3

Related Questions