1
votes

I am completely new to Windows Azure.

I currently have a local db for my .NET application. I have created an azure account along with a relevant SQL Azure Database.

I am working on adding the C# code in order to pass the data from the local application to the cloud. In order to test this functionality I have added a random user who I want to insert into the Azure DB.

I have used the following tutorial: http://www.windowsazure.com/en-us/develop/net/how-to-guides/sql-database/

I are trying to connect to the Azure SQL Database using a connection string in app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="STAREntities"
       connectionString ="Server=tcp:fkr95b1any.database.windows.net,1433;Database=StarSoftwareDb;User ID=starSoft1@fkr95b1any;Password=xxxxxx;Trusted_Connection=False;Encrypt=True;" />
  </connectionStrings>
</configuration>

This method is being used for registration, this code establishes the connection to the azure database, however it is currently failing on 'conn.Open();'.

SqlConnectionStringBuilder csBuilder;

csBuilder = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["STAREntities"].ConnectionString);

SqlConnection conn = new SqlConnection(csBuilder.ToString());
conn.Open();

On clicking the register button which triggers this code, the program hangs for a long period before throwing the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond.)

Any help or advice here would be greatly appreciated.

UPDATE

I have changed my connection string to the one @Leonardo suggested below. I have also enable 'TCP/IP' and 'Named Pipes' in sql server configuration manager aswell as allowing opening port 1433.

The dashboard for the master DB is now showing successful connections on the table but I am still getting an exception on

conn.Open()
1
Are the database and app in the same DC? If you have virtual networks: are they on the same one? Did you copy and paste the right connection string from the azure console? I setup an azure app last weekend (for the first time ever, just for fun) and it worked just fine using the View SQL Database connection strings link from the database portal, using the ADO.NET string, and adding my password in place of {your_password_here} - Marc Gravell♦
Are you able to connect using SQL management studio or similar software using the same connection server/password? - David S.
A second thought: if this is a web-application, the easiest way to do this is to "Download the publish profile" from the web-site, and use that when publishing; this prompts you for your azure connection strings, and does all the hard work for you. - Marc Gravell♦
Hi Marc, thanks for your reply. The application is run locally, it is a standalone C# application opposed to a web application - I am not using virtual networks. I have already tried using the View SQL Database connection stings link to no avail. I'm really not sure why it's not working... so frustrating. - Jonso Crabsi

1 Answers

1
votes

try this here:
"Server=fkr95b1any.database.windows.net;Database=StarSoftwareDb;User ID=starSoft1@fkr95b1any;Password=xxxxxx;"

and check your firewall settings for the instance! it might be closed for all applications (default setting)