A .NET application, from which a connection is being made and query executed as follows (wrapped in a try-catch block):
using (SqlConnection conn = new SqlConnection(Configuration.connectionString))
{
    SqlCommand cmd = new SqlCommand(createTransactionQuery,conn);
    conn.Open();
    return cmd.ExecuteNonQuery();
}
The query string is:
createTransactionQuery = "BEGIN " +
                         "BEGIN Transaction" +
                         "  BEGIN TRY " +
                         "      --variables" +
                         "      DECLARE @varStaffID int;" +
                         "      DECLARE @varProductID int;" +
                         "      SET @varStaffID = " + transaction.getStaff().getID() + ";" +
                         "      SET @varProductID = " + transaction.getProduct().getProductID() + ";" +
                         " " +
                         "      --New record in Transactions table " +
                         "      INSERT INTO Transactions (Timestamp_, CustomerID, StaffID, ProductID) " +
                         "      VALUES (SYSDATETIME(),NULL,@varStaffID,@varProductID; " +
                         " " +
                         "      --Update inventory (Products table)" +
                         "      --First retrieve the current quantity of this product" +
                         "      DECLARE @varCurrQuantity int; " +
                         "      SET @varCurrQuantity = (SELECT Quantity FROM Products WHERE ProductID=@varProductID); " +
                         "      --and update it" +
                         "      UPDATE Products " +
                         "      SET Quantity = @varQuantity-1 " +
                         "      WHERE ProductID = @varProductID; " +
                         "  END TRY " +
                         "  BEGIN CATCH " +
                         "      ROLLBACK Transaction " +
                         "  END CATCH " +
                         "COMMIT Transaction" +
                         "END";
This code throws an exception:
System.Exception: Incorrect syntax near 'BEGIN'.
I know that the query string could be created in a better way. However, I want to know what the cause of the problem is, as this exact query is working when it is executed within SQL Server Management Studio itself.
I have made sure the connection string is correct, as it is working exactly as it should in a different part of the application.