klimst6987
klimst6987

Reputation: 91

Logon failed for login due to trigger execution

I try to add the "mdf" database file to the project, I get an error.
How to fix the error?

Error:
The attempt to connect to the database
failed; the following information was received:
Logon failed for login HOME-PC\Root' due to trigger execution.
Changed database context to master'.
Changed language setting to us_english.*

MSSQLLocalDB is installed together with Visual Studio

I did not install SQL Server.
I would not like to install Sql server management studio and SQL Server, but if the problem cannot be solved in another way, then I can do it.

I use:

I found a solution, but I don't know if it suits me and where to enter commands. I'm afraid to make it worse
https://dba.stackexchange.com/questions/218811/logon-failed-for-login-due-to-trigger-execution

When I try to fully post a question, stackoverflow.com gives me comments on the design. I don't understand how to eliminate these comments. That's why I'm posting the question in an online editor.

Follow the link -> [Detailed question.]

Upvotes: 9

Views: 7602

Answers (2)

cleftheris
cleftheris

Reputation: 4859

For me Error 17892 went away by deleting the old LocalDb instance that is created by default when visualstudio is installed and creating a new one with the same name.

So follow these steps.

  1. open powershell on your machine and run the following commands.

  2. SqlLocalDb info
    

    it should list all the localdb instance names in your machine. The result should show just one result
    MSSQLLocalDB

  3. SqlLocalDb stop "MSSQLLocalDB"    # if necessary
    SqlLocalDb delete "MSSQLLocalDB"
    

    it should delete your existing instance that is not working which will allow for a new instance by the same name to be created. Don't worry it will not delete your database files. The result should show :
    LocalDB instance "MSSQLLocalDB" deleted.

    • Edit: In case your instance is already running try stopping it before trying the delete command using the statement: SqlLocalDb stop "MSSQLLocalDB"
  4. SqlLocalDb create "MSSQLLocalDB"
    

    it should create a new fresh instance with the default name. The result should show :
    LocalDB instance "MSSQLLocalDB" created with version 15.0.4153.1.

  5. SqlLocalDb info "MSSQLLocalDB"
    

    Checks to see the status of your newly created instance. Don't bother that the instance will be shown as stopped, this is normal. It will start upon connection. The result should show:

    Name:               MSSQLLocalDB
    Version:            15.0.4153.1
    Shared name:
    Owner:              MACHINE_NAME\username
    Auto-create:        Yes
    State:              Stopped
    Last start time:    29/06/2022 3:16:59 pm
    Instance pipe name:
    

Thats it!

Now open VisualStudio or the MSSQL Management Studio and connect to your instance it should be fine. You can attach any existing database (Your mdf and ldf files will sill be there under your %USERPROFILE% folder.

You can read more about the sqlLocalDb.exe here

Upvotes: 21

Ali.h
Ali.h

Reputation: 31

I got this error in .Net Core 5 when i had changed my database to another server and wanted to run update-database command the problem for me was that i had 2 Sql Server on the same server and since the sa user is public between different versions it couldn't connect to the database that i wanted. the default port for the Sql Server on install is 1433 and when you install another version of the Sql Server you should assign a port and enable TCP/IP for it. to do this you should open Sql Server [Your Sql Version] Configure Manager and at last restart sql server

Open Sql Server Configure Manager

enter image description here

enter image description here

enter image description here

enter image description here

Upvotes: 0

Related Questions