Cannot connect to SQL Server database: login failed for user 's'

I cannot just connect to my database due to this error

Login failed for user '

Consider these lines of code:

SqlConnection conn = new SqlConnection("Data Source=arohbi;Initial Catalog=SPADA_FIS;Persist Security Info=True;User ID=sa; Password=p@ssword "); conn.Open(); 

After running conn.Open() I received this strange error message

Login failed for user '.'

Last time I used this configuration and connection string, and it works fine, but one fine day, when I try to connect this message, this is the only answer. However, I manage to connect using the management studio. The connection from the server database to my local machine works fine. Any guy knows the answer.

This time it gets worse. Take a look at these images: enter image description here

enter image description here

I used the same connection string for both sqlconnection connections, but I was confused why the other failed?

The connection string used for both:

 Data Source=arohbi;Initial Catalog=SPADA_FIS;Persist Security Info=True;User ID=espada; Password=p@ssword 
+4
source share
2 answers

There are three main reasons that I can come up with from the top of my head that can cause this:

1) The user's password has expired or differs from the one specified by you.

2) User sa was disconnected, either he was denied permission to connect to the database engine, or the input was disabled.

3) Your SQL server instance is not configured for SQL authentication.

+9
source

Whenever you try to fix a problem like this, flip it to the simplest reproducible case. Right now you have a user client trying to connect and interpreting exceptions. Try connecting to an exchange client (i.e. Management Studio) and see what happens.

However, there are other answers here. Based on the error message you receive, either the password to log into the system is disabled, or the password that you use for it is incorrect. Contact your server administrator to find out how you can connect.

0
source

Source: https://habr.com/ru/post/1384637/


All Articles