title: Executing Multiple Non-SELECT MySQL Statements as a Single Command Text in .NET
body: <p>I've been jumping from one thread to another but I can't seem to find the answer that I need.</p>
  
  <p>I wanted to execute non-SELECT MySQL statements in a single ExecuteNonQuery function using .NET.</p>
  
  <p>Here is a sample group of SQL statements I wanted to run:</p>
  
  <pre><code>DROP procedure IF EXISTS `SubProcA`;
  DROP procedure IF EXISTS `SubProcB`;
  DROP procedure IF EXISTS `SubProcC`;
  
  
  CREATE PROCEDURE 'SubProcD'()
  BEGIN
  SELECT
       (&lt;Subselect Statement&gt;) AS A
       ,(&lt;Subselect Statement&gt;) AS B
       ,(&lt;Subselect Statement&gt;) AS C;
  END;
  
  
  CREATE PROCEDURE 'SubProcE'(
       VarA TEXT,
       VarB VARCHAR(255),
       VarC VARCHAR(255),
       VarD tinyint(1)
  )
  BEGIN
       SET @Query = "";
       SET @Query = &lt;Select Statement&gt;;              
       PREPARE Statement FROM @Query;
       EXECUTE Statement;
       DEALLOCATE PREPARE Statement; 
  END;
  </code></pre>
  
  <p>As you can see, there are five statements in there (3 DROPs and 2 CREATEs). What I do in .NET is:</p>
  
  <pre><code>    CommandText = &lt;The SQL Statement above stored in a String variable&gt;
      Connection.Open()
      Command.CommandType = CommandType.Text
      Command.ExecuteNonQuery()
      Connection.Close()
  </code></pre>
  
  <p>Assuming that the sql statements have no syntax error whatsoever, I still get an error when running the code.</p>
  
  <p>I tried chopping the sql statements of (running one statement) and it pushes through.</p>
  
  <p>Am I suppose to put some special character in there or something?</p>