I'm trying to add an Azure SQL Server connection string into my app.config
file, but there are red underlines all over the connection string when I try to copy and paste it from Azure. I'm using Windows Forms in Visual Studio.
Here is my connection string:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="AddSales"
Server="tcp:Sales99.database.windows.net,1433;Initial" Catalog="Sales;Persist" Security="" Info="False;User" ID=""{your_username};Password=""{your_password};MultipleActiveResultSets=""False;Encrypt=""True;TrustServerCertificate="False;Connection" Timeout="30"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Is there a way to fix this issue? Please advise.
Your config is just plain wrong - you need to have an attribute connectionString
in your config that contains all the details about the connection - something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="AddSales"
connectionString="Server=tcp:Sales99.database.windows.net,1433;Initial Catalog=Sales;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I also had this issue when I try to copy & paste connection string from the Azure database. This is connection string that worked for me.
Server=tcp:[serverName].database.windows.net;Database=myDataBase; User ID=[LoginForDb]@[serverName];Password=myPassword;Trusted_Connection=False; Encrypt=True;
This also works.
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=tcp:ServerName.database.windows.net,1433;Initial Catalog=DatabaseName;Integrated Security=False;User Id=username@servername;Password=password;Encrypt=True;TrustServerCertificate=False;MultipleActiveResultSets=True" />
If you need additional info, please visit these sites:
https://www.connectionstrings.com/sql-azure/
https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With