Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a ASP.NET Web Application project which contains a Signup page. I have successfully published the work I've done so far to Azure and they are accessible through the azure project link. Now I need to insert those values from the Signup form to an Azure SQL Database I have created on the portal.

I have created the DB on azure portal, created the tables as well. How do I insert? Is it the traditional SQL insert statements?
Posted

1 solution

Yes, the SQL is always the very same SQL that you learn and use in different database-related applications. However, the only thing you should worry about is the configuration of your application to connect to the Azure SQL database services.

In your web.config file, you can set all of the configuration settings; including the SQL connections to database. From this MSDN documentation[^], you would specify the connection string for your database in such a way,

HTML
<connectionstrings>
  <add name="SQLAzureConnection" connectionstring="Data Source=<ProvideServerName>.database.windows.net;Initial Catalog=TestDb;User ID=<ProvideUserName>;Password=<ProvidePassword>;Encrypt=true;Trusted_Connection=false;"
    providerName="System.Data.SqlClient" />
</add></connectionstrings>


Now fill these values, the servername and other basic information like the database name and the username/password combination for your website (on the azure server).
 
Share this answer
 
v2
Comments
Member 11065384 21-Feb-15 8:54am    
Superb! And I just have to have a normal SQL INSERT query and I'm good to go yeah? :) I don't have to publish the local DB with the website or anything?
Afzaal Ahmad Zeeshan 21-Feb-15 8:57am    
Yes, you can simply just write SQL commands to perform SQL tasks. It would be good as perfect.

Anyways, if you're having the database on your own machine, you would have to deploy your database on the Azure server too. But, if you're going to insert the data there, then you don't need to upload your version of database too.
Afzaal Ahmad Zeeshan 21-Feb-15 9:35am    
If that solution works then you can close this thread by accepting my answer; click on the green button to accept the answer.

Secondly, this is another question of yours. Which can be answered as; server didn't remember the username and/or password that you passed with the connection string. You need to make sure that the Azure also has a user with this username and password.
Member 11065384 21-Feb-15 9:36am    
I'm actually getting this exception in return sir :)

System.Data.SqlClient.SqlException (0x80131904): 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.
Afzaal Ahmad Zeeshan 21-Feb-15 9:37am    
The server was not found or was not accessible. Either make sure that the names are correct; also said in my comment above, or you need to make sure that the connection can be established; internet connection is not faulty.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900