title: Read .sql script with parameters
body: <p>I have a .sql script that contain the following code </p>
  
  <pre class="lang-sql prettyprint-override"><code>-- Drop stored procedure if it already exists
  USE Temp
  
  IF EXISTS (
    SELECT * 
      FROM INFORMATION_SCHEMA.ROUTINES 
     WHERE SPECIFIC_SCHEMA = N'Custom'
       AND SPECIFIC_NAME = N'RestoreVersion' 
  )
     DROP PROCEDURE Custom.RestoreVersion
  GO
  
  CREATE PROCEDURE Custom.RestoreVersion
      @ID INT
  AS
      SELECT * FROM [App].[Version] WHERE ID = @ID
      DROP PROCEDURE Custom.RestoreVersion
  GO
  
  EXECUTE Custom.RestoreVersion @ID = [ID from c# program]
  GO
  </code></pre>
  
  <p>I would like to take this file and set the @ID parameter in c# and then run the sql script. </p>
  
  <p>I want this script to live in a folder on my application but I can't get it to work. </p>
  
  <p>I tried this.  </p>
  
  <pre><code>Console.Write(Server_Name + Environment.NewLine);
  connectSqlServer(Server_Name);
  
  SqlDataReader rdr = null;
  
  Console.WriteLine("\nGet Version\n");
  try
  {
      SqlCommand cmd = new SqlCommand("Custom.RestoreVersion", conn);
  
      cmd.CommandType = System.Data.CommandType.StoredProcedure;
  
      cmd.Parameters.Add(new SqlParameter("@ID", ID));
  
      rdr = cmd.ExecuteReader();
  
      while (rdr.Read())
      {
          Console.WriteLine(Values);
      }
  }
  finally
  {
      if (conn != null)
      {
          conn.Close();
      }
      if (rdr != null)
      {
          rdr.Close();
      }
  }   
  </code></pre>
  
  <p>However I am unable to get this to read the file from the Resources folder and enter the parameters to the database. </p>