views:

133

answers:

3

I've always relied heavily on Windows shortcuts to SSMS that include command-line switches allowing me to quickly open up a specific database on a specific server. For example

Ssms.exe -S 123.123.123.123 -U sa -P goodpassword -d DbName

or

Ssms.exe -S . -E -d DbName

These suddenly stopped working. I get this error from SSMS:

Failed to create new SQL Server script.
Object reference not set to an instance of an object. (AppIDPackage)
Program Location: at Microsoft.SqlServer.Management.UI.VSIntegration.
AppIDPackage.AppIDPackage.OpenConnectionDialogWithGlobalConnectionInfo()

alt text

I can still launch SSMS without the command-line switches, and then manually establish the connections. Some command-line switches still work, for example

ssms.exe -nosplash

works fine.

I get the same error with any combination of the -S, -E, and -d command-line switches. It doesn't matter if I'm pointing to a valid server or database or not, or if my login credentials are good or not. I can point to the older version of SSMS and it works fine, but not the 2008 version.

This post on MSDN's forums is all I've found online, but MS hasn't been very helpful on this thread.

Any ideas how I might start to fix this? I work with a lot of different databases on different servers, and I really rely on these shortcuts.

A: 

Works fine like this:

sqlwb.exe -S . -E -d dbName
djangofan
sqlwb.exe is SQL Server Management Studio 2005 - ssms.exe is 2008. I have 2005 installed but I'd prefer to use 2008.
Herb Caudill
A: 

I'm using SSMS2008 against a SQL2005 database, and the ssms command line works fine here.

This is the version info produced by the SSMS About dialog:

Microsoft SQL Server Management Studio              10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC)             6.0.6001.18000 (longhorn_rtm.080118-1840)
Microsoft MSXML                                     2.6 3.0 5.0 6.0 
Microsoft Internet Explorer                         8.0.6001.18813
Microsoft .NET Framework                            2.0.50727.3074
Operating System                                    6.0.6001

There are several sources (MSSqlTips, and here) that state the command line arguments are available on sqlwb.exe. Yet the Books Online page for ssms states that the options are available on ssms.

mdma
Good to know that it works for you. It was working for me until recently. According to MSDN http://msdn.microsoft.com/en-us/library/ms162825.aspx the same command-line switches should work for ssms.exe as worked for sqlwb.exe.
Herb Caudill
Here's the info from my About dialog: Microsoft SQL Server Management Studio 10.50.1600.1Microsoft Data Access Components (MDAC) 6.1.7600.16385Microsoft MSXML 3.0 4.0 5.0 6.0 Microsoft Internet Explorer 8.0.7600.16385Microsoft .NET Framework 2.0.50727.4927Operating System 6.1.7600
Herb Caudill
+1  A: 

I've thrown the DLL in question at reflector and it's given me back the code at the bottom of this post, sadly there's nothing immediately obvious in the code that makes it easy to work out why it's stopped working for you (wouldn't it be nice if Microsoft shipped debug symbols with anything they produce that's written against the CLR?).

There are a couple of places where the code makes me wonder if you might have a corrupted "recently used servers" list or something similar, perhaps you could try following the steps listed in this question to clear them out and see if that helps.

private void OpenConnectionDialogWithGlobalConnectionInfo()
{
    if ((ServiceCache.GlobalConnectionInfo != null) && (ServiceCache.GlobalConnectionInfo.Count != 0))
    {
        try
        {
            using (ConnectionDialog dialog = new ShellConnectionDialog())
            {
                IDbConnection connection;
                dialog.ImportRegisteredServersOnFirstLaunch = true;
                dialog.AddServer(new SqlServerType());
                UIConnectionInfo connectInfo = ServiceCache.GlobalConnectionInfo[0].Copy();
                if (dialog.TryToConnect(this.PopupOwner, ref connectInfo, out connection) == DialogResult.OK)
                {
                    this.ScriptFactory.CreateNewBlankScript(ScriptType.Sql, connectInfo, connection);
                }
            }
        }
        catch (Exception exception)
        {
            ExceptionMessageBox box = new ExceptionMessageBox(new ApplicationException(SRError.FailedToCreateNewSqlScript, exception));
            box.Caption = SRError.MessageBoxCaption;
            box.Show(this.PopupOwner);
        }
    }
    ServiceCache.GlobalConnectionInfo = null;
}
Rob
Herb Caudill
Glad I could be of help, to be honest I wasn't expecting this to answer the question for you, still, weyhey! :) Refletor, yet again, proves its worth.
Rob