0

Please tell what is wrong with my connection string. I only copy the connection string from azure right now it is showing an error "Format of the initialization string does not conform to specification starting at index". When I tried to replace the double quote with single quote it says the it is missing the providerName attribute but the provider name is already included. My connection string, also I am using Entity Thank you. I know this has been asked before but I couldn't see what is wrong. What am I missing?

 <add name="sample" 
     connectionString="metadata=res://*/Models.ClearanceModel.csdl|res://*/Models.ClearanceModel.ssdl|res://*/Models.ClearanceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;server=tcp:uppdevsecond.database.windows.net,1433;
     initial catalog=sample;Persist Security=False;UserID=sample;Password=sample;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.EntityClient" />
2
  • Try replacing this Timeout=30;" providerName with this Timeout=30;&quot;" providerName. See various examples on this page stackoverflow.com/questions/5781059/… you are missing a closing &quot Commented May 15, 2021 at 7:02
  • 1
    Thank you it's working now. I tried putting the &quot earlier before I posted the question but it gave an error that "Persist security" is not a supported keyword so I assumed it must be wrong because it is provided by azure. But I look at the link you posted and in there I noticed that the connection string is different. I may have deleted some keywords due to constant editing. Thank you. Commented May 15, 2021 at 7:17

2 Answers 2

0

&quot is an escaped version of ". You can't have an opening &quot without a closing &quot

I've added line feeds for clarity but the bit you're missing is after Connection Timeout=30

 <add name="sample" 
     connectionString="metadata=res://*/Models.ClearanceModel.csdl|res://*/Models.ClearanceModel.ssdl|res://*/Models.ClearanceModel.msl;provider=System.Data.SqlClient;
provider connection string=&quot;server=tcp:uppdevsecond.database.windows.net,1433;
initial catalog=sample;
Persist Security=False;
UserID=sample;
Password=sample;
MultipleActiveResultSets=False;
Encrypt=True;
TrustServerCertificate=False;
Connection Timeout=30&quot;" providerName="System.Data.EntityClient" />

I found a bunch of examples here Connection Strings for Entity Framework

Sign up to request clarification or add additional context in comments.

1 Comment

I see so that's why it started at the connection string and ended at connection timeout. Thank you
0

Always check the format of your connection string. I will post the correct connection string format that I used, hopefully this could help other's in the future who will encounter the same problem.

  <add name="sampleName" 
         connectionString="metadata=res://*/Models.YourModel.csdl|res://*/Models.YourModel.ssdl|res://*/Models.YourModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;server=YOUR SERVER;
         initial catalog=YOUR DATABASE;Persist Security Info=False;User ID=YOUR USERNAME;Password=YOUR PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30&quot;" providerName="System.Data.EntityClient" />

Add do not forget those "&quot"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.