question

ReidArchibald-4995 avatar image
0 Votes"
ReidArchibald-4995 asked AlbertoMorillo answered

Connection to SQL Database in Azure

I am trying to set up a simple web site using Azure. My program simply links to a database and lists the contents.
I am getting an error message which says that it can't connect the User to the database and provides an error schedule as follows :

SqlException: Login failed for user 'RArch'.
Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)

I can access the remote db from SQL Server management studio and I can run the program locally and access the database remotely.

I would think from this that the Connection string is correct and the user details are correct.

I don't understand the DbConnectionPool issue - it is beyond my current knowledge level.

Can anyone assist with sorting this out. thanks.

azure-sql-database
· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @ReidArchibald-4995 Welcome to Microsoft Q&A Thanks for posting your questions.

As we understand the ask here is you are facing an issue in connecting the database on setting up a website in Azure.
Can you please check your configuration and try updating the password and check. also, share your connection string or any screenshot to better assist you.

Regards
Geetha

0 Votes 0 ·
ReidArchibald-4995 avatar image ReidArchibald-4995 GeethaThatipatri-MSFT ·

Server=tcp:webapplication6dbserver.database.windows.net,1433;Initial Catalog=Transfer;Persist Security Info=False;User ID=RArch;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;


This is the current connection string.I have inserted my user password into the string in the space indicated in the current program.

I cannot see where to update the password for the database user. Could you direct me to this.

thanks for your assistance.

0 Votes 0 ·

Hi @ ReidArchibald-4995 Thanks for sharing the connection strings.
I tried to create one in my environment and I didn't find any issues, also If you are following any other document please do share the url or provide the steps you followed so I can assist you better.

Could you try as below and let me know
189409-image.png

Regards
Geetha



0 Votes 0 ·
image.png (29.8 KiB)

Geetha,
Thanks for your assistance. . I wanted to let you know that I will be away from my office travelling for the next week and can't work on this matter again until I return. I will get back to you then.
Regards,
Reid

0 Votes 0 ·

Sure @ReidArchibald-4995 Thanks for your response, we will continue to engage when you are available.

Regards
Geetha

0 Votes 0 ·

Hi @ ReidArchibald-4995 Thanks for sharing the connection strings.
I tried to create one in my environment with SQL Authentication and I didn't find any issues, please follow this document and give it a try also please do share the code snippet or provide the steps you followed so I can assist you better.

Here is my connection string

189465-image.png

Regards
Geetha

0 Votes 0 ·
Show more comments
GeethaThatipatri-MSFT avatar image
0 Votes"
GeethaThatipatri-MSFT answered ReidArchibald-4995 commented

Hi @ReidArchibald-4995 Thanks for sharing the screenshot, I am attaching the sample code which is working for AAD connection.
I have added the connection string to your code and I hope you are using the correct dependency192389-image.png

Here is the connection string
string ConnectionString = @"Server=.database.windows.net; Authentication=Active Directory Default; Database=mytestdb1;";

         using (SqlConnection conn = new SqlConnection(ConnectionString))
         {
             conn.Open();
         }

Document for reference

Sample code192368-program.txt

Please let me know if the information is helpful.

Regards
Geetha



image.png (4.4 KiB)
program.txt (3.2 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Geetha,
Thanks for the suggestion but this only led to many more problems and the same connection error issue. I have researched the issue further through help and support forums and the majority of solutions were based around there being problems with setting up the user and password. I went back into the Azure portal and reset my password for the current user and then extracted the recommended connection string again. I reentered this information and the site worked after these changes. I was amazed but delighted to have something working. I seem to have the right combination in place now so will push on with my site.
Many thanks for hanging in there to find a solution.
Regards,
Reid

0 Votes 0 ·

Hi, @ReidArchibald-4995 Happy to see that your issue is now resolved, and thanks for sharing your solution.

Thank you for visiting the Microsoft QA forums! Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community

Regards
Geetha

0 Votes 0 ·
AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered

Please try to set Connection Timeout=60. Other users have reported this as solution.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.