title: C# SMO Executenonquery failed for database
body: <p>My code lines(I am still a rookie. ) ;
  I was trying to export the table on C# so after searching and trying hours I got this problem </p>
  
  <pre><code>private void Button_Click(object sender, EventArgs e)
  {
      Server server = new Server();
  
      Database sourceDB = server.Databases["KaynakDB"];
      Table table = sourceDB.Tables["AnaTablo"];
  
      Database targetDB = server.Databases["KopyaDB"];
  
      foreach (String query in table.Script())
          try
          {
              targetDB.ExecuteNonQuery(query);
          }
          catch (Exception asd)
          {
              MessageBox.Show(asd.Message);
          }
  } 
  </code></pre>
  
  <p>Error Message is</p>
  
  <pre><code>FailedOperationException was unhandled
  
  An unhandled exception of type 'Microsoft.SqlServer.Management.Smo.FailedOperationException' 
  occurred in Microsoft.SqlServer.Smo.dll
  </code></pre>
  
  <p>When I go to the "Details" page it says <strong>"ExecuteNonQuery failed for Database "KopyaDB"</strong>."</p>
  
  <p>Also the "try-catch" says the same too.</p>
  
  <p>Am I missing something?</p>