我有一个指向 oracle 数据库的连接管理器。然后我需要将该连接用于 ssis 脚本任务。我不知道如何继续。我尝试了一些东西,但收到一条错误消息,你能帮忙吗我。这是我的代码:我也尝试使用那些连接字符串:
// 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;
最佳答案
您正在尝试使用 SqlConnection
,它是用于 SQL Server 而不是用于 Oracle 的 .Net 组件。您需要 Oracle.DataAccess.Client
和 OracleConnection
。要使用它,您需要将 Oracle .Net 提供程序添加到 Script
任务的 References
(编辑脚本任务 .Net 代码时请参阅项目资源管理器 References 节点),添加Oracle.DataAccess
,然后在您的代码中编写“using Oracle.DataAccess.Client;
”。
关于c# - oracle连接到c#ssis脚本任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30363932/