title: Executing SQL query from VBA - run time error
body: <p>I try to execute the simplest and shortest query from VBA on SQL-Server using ADO. What am I doing wrong?</p>
  
  <pre><code>Sub VBA_to_SQL()
      Dim cnn As ADODB.Connection
      Dim ConnectionString As String
      Set cnn = New ADODB.Connection
  
      cnn.ConnectionString = "driver={SQL Server};server=MyServerName;Database=MyDataBaseName;Trusted_Connection=yes;"
      cnn.Open
  
      If cnn.State = adStateOpen Then
         Set rs = cnn.Execute("begin transaction insert_value; delete from dbo.MyTable;COMMIT TRANSACTION insert_value;")
          cnn.Close
          MsgBox "Got through!"
      Else
          MsgBox "Sorry. No way today."
      End If
  End Sub
  </code></pre>
  
  <p>I keep getting an error on the line <code>Set rs = cnn.Execute("begin transaction insert_value; delete from dbo.MyTable;;COMMIT TRANSACTION insert_value;")</code>
  The error message is <em>Run-time error '-2147217908 (80040e31)'</em></p>
  
  <p>If I comment the error-causing line I manage to get through to the server. So the connection is established, however the query is not executed. </p>
  
  <p><strong>Update</strong> This code worked well for several days and all of a sudden stopped. Too bad!</p>