SQL Azure Connection Error: "Server name cannot be determined. It must appear as the first segment..." - Visual Studio 2010 Beta 2

While working on SQL Azure connectivity from Visual Studio 2010, I faced the above error.  The full error text is as below:-

Server name cannot be determined.  It must appear as the first segment of the server's dns name (servername.database.windows.net).  Some libraries do not send the server name, in which case the server name must be included as part of the user name (username@servername).  In addition, if both formats are used, the server names must match. “

As the message suggested, I tried putting the username@servername but it didn’t help.  The strange this was, the same connection string worked from Visual Studio 2008.  Let me add more clarity to this.

With SQL Azure, you can migrate your on-premise database to SQL Azure (read my previous post on this) and thereafter, just change the connection string in your Web / Desktop Application Configuration file to point to the SQL Azure Database.  The SQL Azure portal provides the connection string in the following format

Server=tcp:SERVERNAME.database.windows.net;Database=DATABASENAME;User ID=USERNAME;Password=myPassword;Trusted_Connection=False;Encrypt=True;

So, in normal cases, you can create an application and do a data binding to get the connection string inserted into the configuration file.  Later, once you migrate the data into the SQL Azure service, you can just change the connection string to the above (after adding the correct Servername, UserId, Password, Database name etc.,)

I did the above steps in Visual Studio 2008 and the application showed zero difference between binding from the local database instance and from the SQL Azure instance.

However, when I was trying this in Visual Studio 2010 Beta 2, the local instance bound properly (as expected) and when I replaced the connection string with the SQL Azure Database connection string, it started throwing the error explained in the beginning of the post.

The change I had to make was, in the connection string, for the User ID I had to specify USERNAME@SERVERNAME example rajiv@sdkldfldfdfd  (both username and servername are imaginary.  note the servername is just the name of the server and not the fully qualified path with .database.windows.net etc., which is not required)

Post this change, the application was able to bind data from the SQL Azure Database without any issues.

So, for Visual Studio 2008, it was simply username and for Visual Studio 2010, it required username@servername

Cheers !!!

Print | posted on Thursday, December 17, 2009 6:14 AM

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)