If you add the string [user instance = true] to the connection string, an exception is thrown

Exception Details:

System.Data.SqlClient.SqlException: Unable to open the database of the login request "RealtyDB" Authorization failed. The account error 'FAFHN24BNK43 \ JKAD754' failed.

My connection string looks like this:

add name = "ApplicationServices" connectionString="data source=.\SQLEXPRESS;User Instance=True;Initial Catalog=RealtyDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" 

If I remove [User Instance=True;] , my application will be fine.

Does anyone know why?

+4
source share
2 answers

I have ever seen a user instance function used in conjunction with AttachDbFileName . In other words, you cannot connect to a database that is already connected to a running instance of SQL Server and tell SQL Server to create a new instance for this database, since only one instance can “own” the database for a while. When you use AttachDbFileName , it tells SQL Server to make a copy of this MDF file to use the application.

So, if this is not the way you are going to use this function, I again suggest that you simply take the User Instance = true parameter from your connection string.

(It may also be interesting to note that this dubiously useful feature is deprecated.)

+6
source

I agree with Aaron Bertrand. The connection string should be like this:

connectionString = "data source =. \ SQLEXPRESS; Integrated Security = SSPI; AttachDBFilename = | DataDirectory \ appdb.mdf; User Instance = true"

+1
source

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


All Articles