Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS Azure integration run time - OLEDB connection works for connecting on premise SQL server but ADO.net connection does not

$
0
0

Hello All,

I am trying to access onprem SQL server within SSIS package that is configured to execute with azure integration run time.

Within package , I have Execute SQL task which is used to query from onprem SQL Server with OLEDB connection manager and it works fine.

When i try to access the onprem server within script component it gives me below error -

[Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]

Below is the code snippet - 

           

string SourceConString = "Data Source = " + Dts.Variables["var_SourceServer"].Value.ToString() + "; Initial Catalog = " + Dts.Variables["var_SourceDatabase"].Value.ToString() + "; User ID = "+ Dts.Variables["var_SourceUserID"].Value.ToString() + "; Password = " + Dts.Variables["var_SourcePassword"].Value.ToString();

string DestnConString  = "Data Source = " + Dts.Variables["var_DestnServer"].Value.ToString()  + "; Initial Catalog = " + Dts.Variables["var_DestnDatabase"].Value.ToString()  + "; User ID = " + Dts.Variables["var_DestnUserID"].Value.ToString()  + "; Password = " + Dts.Variables["var_DestnPassword"].Value.ToString();


            using (SqlConnection sourceCon = new SqlConnection(SourceConString))
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM " + "dbo." + Dts.Variables["var_StgTableName"].Value.ToString(), sourceCon);
                sourceCon.Open();
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    using (SqlConnection destinationCon = new SqlConnection(DestnConString))
                    {
                        using (SqlBulkCopy bc = new SqlBulkCopy(destinationCon))
                        {
                            bc.BatchSize = 25000;
                            bc.DestinationTableName = "stg." + Dts.Variables["var_StgTableName"].Value.ToString();
                            destinationCon.Open();
                            try 
                                { 
                                bc.WriteToServer(rdr);
                                }
                            catch
                            { 
                             Dts.Variables["var_DataLoadErrorFlag"].Value = 1 ; 
                            }
                            finally
                            {
                                sourceCon.Dispose();
                                destinationCon.Dispose();
                            }

                        }
                    }
                }
            }

Just to check i created a executed SQL task and assigned it with ADO.net connection manager to connect it with onprem SQL server i am getting below error - 

[Error: Failed to acquire connection "-----". Connection may not be configured correctly or you may not have the right permissions on this connection.]

When i execute the package within local execution environment and not with Azure integration run time , everything works fine.

any suggestion for possible solution will be very helpful.

 


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>