Starting SSMS from within a VB.NET application

  • Hey all.

    I am working on my own management solution for our environment. In a list of failed jobs/backups etc.. I want to be able to right click a connection and then 'open' it using SSMS. In other words, I want to simply right click an entry and then open SSMS and connect to that database.

    I've been scouring the web for a solution because the commandline simply doesn't seem to work from within .NET. I've tried several ways, such as using the SHELL and Process.Start() commands. They open SSMS, but they don't open the connection to the server/database. Also, each time I click it opens a NEW window of SSMS, instead of reusing the already open one. Furthermore, it seems to completely ignore the 'nosplash' option.

    I've already edited the registry entry to add %1 to the entry of SSMS, following advice I saw a lot on the internet, but that didn't change anything.

    My code looks like this:

    Try

    Dim SQLServerInstanceName As String = dgvDiskSize.SelectedRows(0).Cells(0).Value

    Shell("""C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"""" -E -S " + SQLServerInstanceName + " -NoSplash")

    Catch ex As Exception

    MsgBox("Error occured: " + vbCrLf + ex.Message, MsgBoxStyle.Critical, "Oh noes!")

    End Try

    In order to 'cut out' some variables I've been trying the same thing using CMD. When using CMD it does not ignore the nosplash command, and it does open a connection to the database, but it still opens a completely new instance of SSMS every time I click a link, which makes it unusable in this sitation.

    Does anyone have experience with this? Do I need to solve it using windows messaging/DDE or is a commandline start enough?

  • An update.

    I've never managed to fix this. I've tried many, many, different ways of automating SSMS. But it seems to be designed not to allow for this behavior on PURPOSE. If even windows DDE/Messaging can't get this to work then they've seriously obstructed this behavior, perhaps to force you to use their tools? Not sure.

    In any case, this --what should be very easy and works with nearly any other program out there-- is impossible in SSMS.

  • I don't know if it's deliberate or not but typically for your own management type of application they encourage the use of SMO since that's what it was designed for. You may want to look at utilizing that instead of shelling out to SSMS...which as you found likely doesn't work anyway.

    Sue

  • Sue_H (9/13/2016)


    I don't know if it's deliberate or not but typically for your own management type of application they encourage the use of SMO since that's what it was designed for. You may want to look at utilizing that instead of shelling out to SSMS...which as you found likely doesn't work anyway.

    Sue

    Sue, thanks for your reply.

    I already use SMO inside our application, it's technology is irrelevant for what we need, the purpose of the tool is not to replace SSMS.

    The application is a global monitoring app, which helps us to globally check things like disk space etc.. As this information is not available from within SQL Server (we use mounted disks which are not readilly available to the OS) we need to work outside the box using tools such as this.

    A datagridview is filled with SQL servers that have 'one problem or another'. So it's only a KPI program (read: monitoring tool). From there we administer our SQL servers as one always would, using SSMS. It was never the purpose of this app to replace functionality within SSMS.

    Right now we need to manually start SSMS, or manually connect to servers that have an issue. It would be handy to be able to double click an entry, so that SSMS automatically connects to that server, such basic commandline functionality is very standard in most other maintenance tools and applications.

    Compare it to doubleclicking a JPG file and not have Adobe Photoshop create a completely new instance of itself, but reuse the existing running executable, merely opening it in a new window.

  • Hi,

    6 years later, it seems nothing changed.

    Please let us know if you found any workaround.

    Thanks!

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply