title: .NET / Oracle: How to execute a script with DDL statements programmatically
body: <p>I want to do some programmatical schema manipulation against an oracle database in C#. Therefore, I struggle with some basic issues.</p>
  
  <p>The ddl sql statements are located in a script file. I do not want to use sqlplus.exe, but I want to use OracleCommand out of the ODP.NET assemblies (System.Oracle.DataAccess). Here's an example of my script file:</p>
  
  <p>script.sql:</p>
  
  <pre><code>DROP TABLE ABCDEF; 
  
  DROP TABLE GHIJKL;
  </code></pre>
  
  <p>I want to point out:</p>
  
  <ul>
  <li>The script contains DDL statements (data definition language)</li>
  <li>The script contains <strong>empty lines</strong></li>
  <li>The script contains <strong>more than one statement</strong></li>
  </ul>
  
  <p>The following code should execute my script:</p>
  
  <pre><code>var content = File.ReadAllText("script.sql");
  
  using (var oracleConnection = new OracleConnection(_connectionString))
  {
       oracleConnection.Open();
  
       using (var command = new OracleCommand(content) { Connection = oracleConnection })
       {
            command.CommandType = CommandType.Text;
            command.ExecuteNonQuery();
       }
  }
  </code></pre>
  
  <p>Executing this code, I do get an oracle error:</p>
  
  <p><strong>Oracle.DataAccess.Client.OracleException: ORA-00911: invalid character</strong></p>
  
  <p>Maybe there is some issue with the formatting of the statements, I think. Any hint is appreciated. Thank you.</p>
  
  <p><strong>---EDIT---</strong></p>
  
  <p>To summarize my needs in a simple way: I search for an approach to execute any sql/ddl script, that is executable by SQL Plus, programmatically with C#.</p>