Runs OK on my machine but not on the ISP

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

Runs OK on my machine but on the ISP I get.Compiler Error Message: BC30002:
Type 'Microsoft.SqlServer.Management.Smo.Server' is not defined.I have Sql
Server 2008.He has Sql Server Express 2005.We both have framework 3.5.Can I
get around this by supplying a dll?I just need to run a .sql file against
my database thereThanks in advance
 
SMO is SQL Management Objects, generally used for managing the SQL Server.
It would not normally be needed for executing SQL statements, so maybe you
can just remove the reference? You could also check that your connection
string is correct for the SQL Express at the ISP, that the account running
asp.net has the appropriate privileges.
 
Maybe there is a better way but this is the only way I know.

Thanks a lot



Dim fileIn As New FileInfo(Server.MapPath("~/App_Data") & "\" &
TextBoxSqlFile.Text)

Try

Dim sqlConnectionString As String = TextBoxConnectionString.Text

'"Data Source=Dad;Integrated Security=True;Initial Catalog=EmptyDB"

Dim conn = New SqlConnection(sqlConnectionString)

Dim sql As String = fileIn.OpenText().ReadToEnd()

Dim serverq As New Microsoft.SqlServer.Management.Smo.Server(New
ServerConnection(conn))

serverq.ConnectionContext.ExecuteNonQuery(sql)

TextBoxErrorCreate.Text = "Database has been modified successfully"

Catch ex As System.Exception

TextBoxErrorSql.Text = "Error running:" & vbCrLf & fileIn.FullName & vbCrLf
& ex.ToString()

End Try
 
Maybe there is a better way but this is the only way I know.

Thanks a lot

Dim fileIn As New FileInfo(Server.MapPath("~/App_Data") & "\" &
TextBoxSqlFile.Text)

Try

Dim sqlConnectionString As String = TextBoxConnectionString.Text

'"Data Source=Dad;Integrated Security=True;Initial Catalog=EmptyDB"

Dim conn = New SqlConnection(sqlConnectionString)

Dim sql As String = fileIn.OpenText().ReadToEnd()

Dim serverq As New Microsoft.SqlServer.Management.Smo.Server(New
ServerConnection(conn))

serverq.ConnectionContext.ExecuteNonQuery(sql)

TextBoxErrorCreate.Text = "Database has been modified successfully"

Catch ex As System.Exception

TextBoxErrorSql.Text = "Error running:" & vbCrLf & fileIn.FullName & vbCrLf
& ex.ToString()

End Try

Why you're not using SqlConnection???
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection..aspx
 
Back
Top