Once of the cool build-in activity is the Parallel activity which lets the developer execute the tasks in Parallel. This can be highly beneficial when you want the results of a certain executing persist in two different sources. Let's say you alter the dataset and now want to persists it in the database as well as XML file. For this purpose you can make use of the Parallel activity.

Once of the cool build-in activity is the Parallel activity which lets the developer execute the tasks in Parallel. This can be highly beneficial when you want the results of a certain executing persist in two different sources. Let's say you alter the dataset and now want to persists it in the database as well as XML file. For this purpose you can make use of the Parallel activity.



The code behind for this workflow is very straight forward.

 private void PersistInDatabase()
        {
            string connectionString = "Server=localhost;Database=School;Trusted_Connection=true";
            SqlConnection conn = new SqlConnection(connectionString);
           
            SqlCommand myCommand = new SqlCommand("INSERT INTO Users(UserName,Password) VALUES(@UserName,@Password)",conn);
            myCommand.Parameters.AddWithValue("@UserName", "UserName");
            myCommand.Parameters["@UserName"].SourceVersion = DataRowVersion.Current;
            myCommand.Parameters.AddWithValue("@Password", "Password");
            myCommand.Parameters["@Password"].SourceVersion = DataRowVersion.Current;


            SqlDataAdapter ad = new SqlDataAdapter();
            ad.InsertCommand = myCommand;
           
            //ad.Fill(_userDataSet);
            ad.Update(_userDataSet.Tables["UsersTable"]);

        }

        private void WriteToFile(object sender, EventArgs e)
        {
            string path = @"C:\UsersTable.xml";

            _userDataSet.WriteXml(path);                               

           
        }