title: Running a SQL install script with SMO. Alternative solutions needed
body: <p>I've got a web application that uses Microsoft Sql Management Objects (SMO) dll's. I'm wondering how I go about redistributing the libraries for a remote machine. </p>
  
  <p>As I understand it, these come with SQL server or Sql express - which isn't on the remote (shared) webserver. Asking the host to install them, is probably out of the question, so is it possible to dynamically load them? </p>
  
  <p>See below error- </p>
  
  <p>Could not load file or assembly 'Microsoft.SqlServer.Smo, Version=9.0.242.0,   Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.</p>
  
  <p>Alternatively, if anyone can provide a workaround for the below snippet that would also be useful. The script variable is a SQL install script which has been read to the end. The nice thing about this is the outputting of each of the execute strings from SQL. I could of course just execute it all in one chunk, but that provides no visual feedback to the user line by line, that the sql is executing ok.</p>
  
  <p>Is there a stored procedure that could perform this sort of thing? Or an alternative way to execute an install script without full permissions.</p>
  
  <pre><code>           Dim connection As New SqlConnection(Me.ConnectionString)
  
              connection.Open()
              connection.Close()
  
              Dim server As New Server(New ServerConnection(connection))
              server.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql
              Dim commands As StringCollection = server.ConnectionContext.CapturedSql.Text
              server.ConnectionContext.ExecuteNonQuery(script, ExecutionTypes.ContinueOnError)
  
  
  
  
  
              Dim s As String
              For Each s In server.ConnectionContext.CapturedSql.Text
                  AppendMessages(s)
              Next
  </code></pre>