title: Why i'm getting error for the Microsoft.SqlServer.Server namespace?
body: <p>I'm writing this code:</p>
  
  <pre><code>string sqlConnectionString = conn1;
  
  //string sqlConnectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True";
  FileInfo file = new FileInfo("d:\\behzadBULK.sql");
  string script = file.OpenText().ReadToEnd();
  
  SqlConnection conn = new SqlConnection(sqlConnectionString);
  Microsoft.SqlServer.Server server = new Microsoft.SqlServer.Server(new ServerConnection(conn));
  server.ConnectionContext.ExecuteNonQuery(script);
  </code></pre>
  
  <p>but I'm getting an error in this line </p>
  
  <pre><code>Microsoft.SqlServer.Server = ....
  </code></pre>
  
  <p>I added the <code>Microsoft.SqlServer.Smo</code> reference, but I get this error:</p>
  
  <blockquote>
    <p>'Microsoft.SqlServer.Server' is a 'namespace' but is used like a 'type'</p>
  </blockquote>
  
  <p>What happen? Thanks.</p>
  
  <p>My error:</p>
  
  <p><img src="https://i.stack.imgur.com/8NCNO.png" alt="enter image description here"></p>