Reputation: 33
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()
Upvotes: 1
Views: 2652
Reputation: 11401
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)
Upvotes: 1