Is SSIS DataReader a fully implemented IDbDataReader?
I was testing a couple of different scenarios for bulk updating data in SQL Data table. I was interested to see if the table value parameter stored procedures would enable me to avoid unnecessary persistence and potentially give me a chance to run parallel updates. Whenever I try to Execute the reader from the SSIS connection I get an error "Failed to convert parameter value from a DataReaderDestinationAdapter to a IEnumerable`1. ________________________________________________________________________ This code fails string dtexecArgs = @"/FILE ""C:\Users\ssharpe\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\TVPMergeREader.dtsx"""; string dataReaderName = "AddressReader"; string sqlConn = "Data Source=localhost;Initial Catalog=VelocityStaging;Integrated security=True"; DtsConnection dtsConnection = new DtsConnection(); dtsConnection.ConnectionString = dtexecArgs; dtsConnection.Open(); DtsCommand dtsCommand = new DtsCommand(dtsConnection); dtsCommand.CommandText = dataReaderName; IDataReader dtsDataReader = dtsCommand.ExecuteReader(CommandBehavior.CloseConnection); SqlConnection conn = new SqlConnection(sqlConn); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "dbo.TVPMergeAddressOCP"; SqlParameter parm = cmd.Parameters.AddWithValue("@AddressOCP", dtsDataReader); parm.SqlDbType = SqlDbType.Structured; cmd.CommandTimeout = 600; if (conn.State == ConnectionState.Closed) conn.Open(); cmd.ExecuteNonQuery(); if (conn.State == ConnectionState.Open) conn.Close(); ________________________________________________________________________ If I simply load up the file as an ODBCDataReader in code it works fine. ________________________________________________________________________ This code succeeds string destConnString = "Data Source=localhost;Initial Catalog=VelocityStaging;Integrated security=True"; string srcFileConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\UnitTests\\;Extended Properties=\"text;HDR=Yes;FMT=Delimited(|)\""; SqlConnection destConn = new SqlConnection(destConnString); OleDbConnection oleConn = new OleDbConnection(srcFileConnString); OleDbCommand cmdSrc = new OleDbCommand(); cmdSrc.Connection = oleConn; cmdSrc.CommandType = CommandType.Text; cmdSrc.CommandText = "SELECT * FROM AddressOCP.txt"; if (oleConn.State == ConnectionState.Closed) oleConn.Open(); IDataReader addressReader = cmdSrc.ExecuteReader(CommandBehavior.CloseConnection); SqlCommand cmdTVP = new SqlCommand(); cmdTVP.Connection = destConn; cmdTVP.CommandType = CommandType.StoredProcedure; cmdTVP.CommandText = "dbo.TVPMergeAddressOCP"; SqlParameter parm = cmdTVP.Parameters.AddWithValue("@AddressOCP", addressReader); parm.SqlDbType = SqlDbType.Structured; cmdTVP.CommandTimeout = 600; if (destConn.State == ConnectionState.Closed) destConn.Open(); cmdTVP.ExecuteNonQuery(); if (destConn.State == ConnectionState.Open) destConn.Close(); if (oleConn.State == ConnectionState.Open) oleConn.Close(); ________________________________________________________________________ My package is pretty straightforward File Source -> DataReaderDestination Sharpester
October 29th, 2010 1:34pm

Hi, Can you point on which exact line the code fails? I see the error mentions it cannot cast to IEnumerable , but there is no such cast in the code you posted.SSIS Tasks Components Scripts Services | http://www.cozyroc.com/
Free Windows Admin Tool Kit Click here and download it now
October 31st, 2010 3:15pm

cmdTVP.ExecuteNonQuery(); is the line that throws the error IDataReader addressReader = cmdSrc.ExecuteReader(CommandBehavior.CloseConnection); is where the cast happens. Sharpester
November 1st, 2010 12:49pm

cmdTVP.ExecuteNonQuery(); is the line that throws the error IDataReader addressReader = cmdSrc.ExecuteReader( CommandBehavior .CloseConnection); is where the cast happens. Sharpester Your description is not clear. From your initial post you stated that code above works. You are now mixing the working and non-working posts. Please review the information again. Another thing to consider is that you should not use OleDbCommand or SqlCommand to work with the DataReaderDestination object. This would somehow imply that the object is SQL's ADO.NET implementation or OLEDB's ADO.NET implementation , which it is not. You have to limit yourself only to using the base ADO.NET classes and interfaces.SSIS Tasks Components Scripts Services | http://www.cozyroc.com/
Free Windows Admin Tool Kit Click here and download it now
November 1st, 2010 1:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics