Reputation: 279
ALTER DATABASE test SET ENABLE_BROKER
this is the sql query i wish to execute while program is executing.. because i do not want to everytime i change computer also need open sql management tool to execute this query rath
Upvotes: 1
Views: 22719
Reputation: 73
Better late than never. Missing opening and closing of the connection. In case anyone needs it:
Dim connection As SqlConnection
connection = New SqlConnection("Data Source=myServerAddress;" & _
"Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;")
connection.Open()
Dim command As SqlCommand
command = connection.CreateCommand()
command.CommandText = "ALTER DATABASE test SET ENABLE_BROKER"
command.ExecuteNonQuery()
connection.Close()
Upvotes: 2
Reputation: 238076
You can fire alter database
like a regular SQL statement:
Dim connection As SqlConnection
connection = New SqlConnection("Data Source=myServerAddress;" & _
"Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;")
Dim command As SqlCommand
command = connection.CreateCommand()
command.CommandText = "ALTER DATABASE test SET ENABLE_BROKER"
command.ExecuteNonQuery()
Upvotes: 9