简体   繁体   中英

SQL Server Express login failed for user domain\name

I created ac# program with the connection string

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|APSDB.mdf;Database=APSDB; Initial Catalog= APSDB; Trusted_Connection=True; User Instance=true;

It works using the computer I created it with, but upon using Advanced Installer and deploying it to my laptop to test if it works on a different environment, it utterly fails. The program runs, but once I do anything that accesses the database, it gives me the error:

login failed for user domain\\name.

I have checked the SQL Server Error Log, there is no Error 18456, State 38 anymore. It just says:

2016-08-24 17:32:03.57 spid69s Starting up database 'APSDB'

2016-08-24 17:32:03.57 spid69s [INFO] HkHostDbCtxt::Initialize(): Database ID: [6] 'APSDB'. XTP Engine version is 0.0.

2016-08-24 17:32:03.57 spid69s [INFO] HkHostDbCtxt::Initialize(): Database ID: [6] 'APSDB'. XTP Engine version is 0.0.

2016-08-24 17:32:03.57 spid69s [INFO] HkHostDbCtxt::Initialize(): Database ID: [6] 'APSDB'. XTP Engine version is 0.0.

Upon changing the account SQL Server Express is using to start to my Local System, and re-run everything, on the error log it says that:

Login Succeeded for User domain\\name

but alas, the problem persists with my program.

Search in logs SQL Server the next error: "Error 18456, severity: 14. Estate: 38 Login failed for user 'YourUser'. Reason: the database cannot be opened 'YourDataBase'... "

Show in the properties of user in the Tab "User Mapping" if the database have check and correct permissions.

If you don´t have check and push the check show the error "Microsoft SQL Server, Error: 15405" you cah to do the next:

USE myDB exec sp_changedbowner 'sa', 'true'

And see you that option of Database AUTOCLOSE is FALSE. https://blog.sqlauthority.com/2016/02/20/sql-server-starting-up-database-why-multiple-times-in-errorlog/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM