Error connection to Azure Database

Oct 8, 2009 at 9:54 AM

Hi, I have just downloaded the application (and tried running from the source through Visual studio 2008 and get the following error when trying to connect to Azure SQL:

"Unable to cast object of type 'System.DBNull' to type 'System.String'."

I am using the server name, and the same credentials that work when connecting via SSMS or my application.

Are there any pre-requisites I need to know about?

Stack Trace:

at Microsoft.SqlServer.Management.Common.ServerConnection.get_TrueName()
   at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetUrnRecursive(StringBuilder urnbuilder, UrnIdOption idOption)
   at Microsoft.SqlServer.Management.Smo.Server.GetUrnRecursive(StringBuilder urnbuilder, UrnIdOption idOption)
   at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetUrnRecursive(StringBuilder urnbuilder)
   at Microsoft.SqlServer.Management.Smo.SqlSmoObject.get_Urn()
   at Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitChildLevel(Urn levelFilter, ScriptingOptions so, Boolean forScripting)
   at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollection(Boolean refresh)
   at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.GetEnumerator()
   at SQLAzureMW.ScriptWizard.DisplayDatabases() in D:\Development\SQLAzureMW\ScriptWizard.cs:line 977
   at SQLAzureMW.ScriptWizard.btnConnectToServer_Click(Object sender, EventArgs e) in D:\Development\SQLAzureMW\ScriptWizard.cs:line 1737
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at SQLAzureMW.Program.Main() in D:\Development\SQLAzureMW\Program.cs:line 23
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Oct 9, 2009 at 12:53 AM


If you are running SSMS on your machine, then I don't see why SQLAzureMW does not work for you, since I use SMO just like SSMS does.  Check out SQLAzureMW v0.3.0 and see what you get.  If that does not work, maybe we can take this offline and figure out what is going on.


Oct 9, 2009 at 7:49 AM

Hi ghuey

Thanks for the reply, Version 3.0 does the same thing unfortunately, so not sure what the issue is.

I have now built an Azure Database install/upgrade application that suits our need, so will just continue with that.


Mark Redman

Oct 10, 2009 at 1:25 AM

Hi Mark,

I believe that I might have run into the same problem today.  I had a test database in SQL Azure, but SQL Azure did not see it.  Yet, when I got into SSMS, I could do a select against sys.databases and see it.  I could even connect to it via SSMS, yet SQL Azure did not see it and I got a login failure when I tried to connect to it from SQLAzureMW.  So, I ended up deleting the database from SSMS and then I used SQLAzureMW to create a new database and it worked great.  I would suggest that you delete your database and try again from scratch or just start with a fresh DB name and see what happens.