简体   繁体   中英

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;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM