Runs OK on my machine but not on the ISP

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
 
P

Paul Shapiro

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.
 
A

AAaron123

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
 
C

cubaman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top