0

Please, help me to solve the problem with my connection to SQL Server.

I got an error:

SqlException (0x80131904): The target principal name is incorrect. Cannot generate SSPI context.

I've already tried to follow these recommendations (https://learn.microsoft.com/en-US/troubleshoot/sql/database-engine/connect/cannot-generate-sspi-context-error), but without any results.

+Additional information: my connectionStrings file:

<?xml version="1.0" encoding="utf-8"?>
<connectionStrings>
  <add name="redis" connectionString="host=127.0.0.1;db=0;port=6379" />
  <add name="defPackagesWorkingCopyPath" connectionString="%TEMP%\%APPLICATION%\%APPPOOLIDENTITY%\%WORKSPACE%\TerrasoftPackages" />
  <add name="tempDirectoryPath" connectionString="%TEMP%\%APPLICATION%\%APPPOOLIDENTITY%\%WORKSPACE%\" />
  <add name="sourceControlAuthPath" connectionString="%TEMP%\%APPLICATION%\%APPPOOLIDENTITY%\%WORKSPACE%\Svn" />
  <add name="elasticsearchCredentials" connectionString="User=gs-es; Password=DEQpJMfKqUVTWg9wYVgi;" />
  <add name="influx" connectionString="url=http://10.0.7.161:30359; user=; password=; batchIntervalMs=5000" />
  <add name="messageBroker" connectionString="amqp://guest:guest@localhost/BPMonlineSolution" />
  <add name="db" connectionString="Data Source=127.0.0.1;Initial Catalog=BS_BCJ_L_MENU_4118923_0930;Integrated Security=SSPI;MultipleActiveResultSets=True;Pooling=true;Max Pool Size=100" />
</connectionStrings>
siggemannen
  • 3,884
  • 2
  • 6
  • 24
Futorka
  • 1
  • 1
  • Does this answer your question? [SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904)](https://stackoverflow.com/questions/26135346/sql-connection-error-system-data-sqlclient-sqlexception-0x80131904) – Markus Safar Feb 26 '23 at 10:15
  • What does your connection string look like? – marc_s Feb 26 '23 at 10:21
  • I have also done SQL Server Services --> SQL Server Agent is enabled in SQL Server Configuration Manager> – Futorka Feb 26 '23 at 10:33
  • Please **do not** put code samples or sample data into comments - since you cannot format it, it's **extremely hard** to read it.... Instead: **update** your question by editing it to provide that additional information! Thank you. – marc_s Feb 26 '23 at 11:19
  • why do you need sspi over localhost. You should be able to use standard Integrated Security=True – siggemannen Feb 26 '23 at 15:43
  • I've just tried to change "SSPI" to "True" and got the same result. – Futorka Feb 26 '23 at 16:26
  • The connection string doesn't have a username, so that means it is connecting using "integrated authentication". It looks like the user identity running your code is not recognized by the SQL server instance. Probably you are not part of a domain or are not using a domain account to run it. – Ben Feb 27 '23 at 19:51

1 Answers1

0

This works for me : Integrated Security=False

Akmal
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 21 '23 at 12:01
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34866608) – Ram Chander Aug 23 '23 at 19:57