I am trying to use a C# script task in order to insert records into a backend SQL table.
The task fails when it encounters the 4th line of code shown below. It fails when trying to create a new SqlConnection object passing in my connection as a string. I am assuming I need to convert the conString string to something.....
ConnectionManager cm;
cm = Dts.Connections["My SQL Connection Manager"];
String conString = cm.ConnectionString;
SqlConnection myConnection = new SqlConnection(conString);
String myInsertQuery = "INSERT INTO dbo.My_Table(A, B, C) VALUES('AAA', 'BBB', 'CCC')";
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();