2017-05-24 87 views
-1

我收到此代码块中的错误,似乎无法找到问题。错误ExecuteReader:连接属性尚未初始化。在C#脚本SSIS

SqlConnection con = (SqlConnection)(Dts.Connections["connection"].AcquireConnection(Dts.Transaction) as SqlConnection); 
ssqlRiskQuery = "My query"; 

using (SqlCommand command = new SqlCommand(ssqlRiskQuery, con)) 
{ 
    command.Connection = con; 
    using (SqlDataReader reader = command.ExecuteReader()) 
    { 
     while (reader.Read()) 
     { 
      OutputFileObjects.Add(reader["p.provider_id"].ToString(), new string[] { reader["bu.business_unit_id"].ToString(), reader["l.location_id"].ToString(), reader["cpd.claim_number"].ToString(), reader["v2.process_code"].ToString() }); 
     } 
    } 
} 
con.Close(); 
+3

youre not calling con.Open() – Muckeypuck

+0

是的,打开缺少,但错误消息指向SqlConnection为空。我敢打赌,如果她打电话给_con.Open()_NRE被提出 – Steve

+3

如果你添加代码_AquireConnection_ – Steve

回答

0

你需要connection.Open();

你还没有打开连接。

相关问题