title: Error trying to execute SQL Server script file via ExecuteNonQuery on VB.NET
body: <p>The script works great on SQL Management Studio, it just doesn't on the program. The script file checks if certain stored procedures exist, drops them if they do, and next declares them again, like this:</p>
  
  <pre><code>IF EXISTS(SELECT * FROM sys.objects WHERE type='P' AND name = 'myProc1')
    DROP PROCEDURE myProc1
  GO
  CREATE PROCEDURE myProc1
  AS
  BEGIN
    SELECT 
      [Field1] = ((*Some numeric value*)-(*Some numeric value*)),
      [Field2] = ((*Some numeric value*)-(*Some numeric value*)),
      [Field3] = ((*Some numeric value*)-(*Some numeric value*))
    FROM ...
    WHERE ...
  END
  GO
  
  IF EXISTS(SELECT * FROM sys.objects WHERE type='P' AND name = 'myProc2')
    DROP PROCEDURE myProc2
  GO
  CREATE PROCEDURE myProc2
  AS
  BEGIN
    SELECT * FROM Table2
  END
  GO
  
  IF EXISTS(SELECT * FROM sys.objects WHERE type='P' AND name = 'myProc3')
    DROP PROCEDURE myProc3
  GO
  CREATE PROCEDURE myProc3
  AS
  BEGIN
    SELECT * FROM Table3
  END
  GO
  </code></pre>
  
  <p>And when I try to run it on VB.NET I tried this:</p>
  
  <pre><code>sql.CommandText = File.OpenText("C:\test.sql").ReadToEnd()
  sql.CommandType = CommandType.Text
  sql.Connection = connects.con
  sql.ExecuteNonQuery()
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>Incorrect syntax near 'GO'.
  Incorrect syntax near 'GO'.
  Incorrect syntax near 'GO'.
  Incorrect syntax near ')'.
  Incorrect syntax near '-'.
  Incorrect syntax near ')'.
  Incorrect syntax near '-'.
  Incorrect syntax near ')'.
  Incorrect syntax near '-'.
  Incorrect syntax near '�'.
  </code></pre>
  
  <p>So at least 3 GOs, the 3 operations, and even some unknown character.</p>
  
  <p>Any ideas on what I'm doing wrong?</p>