SQL Integrated Security connection string not working after application has been published


I am using integrated security to connect to a sql database.

This is the connection string I am using:

Server=CRAIG_DAFF\\SQLEXPRESS;Initial Catalog=LairageScanning;MultipleActiveResultSets=true;Integrated Security=True;

While working in visual studio I have no problem connecting to the database. But when I install the application as service the application I get the following error:

Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "LairageScanning" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\SYSTEM'.

Unsure as to why this is happening.

asked on Stack Overflow Nov 1, 2020 by Cornelis

1 Answer

  1. Open SQL Management Studio
  2. Connect to SQL Server instance connected to
  3. Navigate to Security
  4. Open the Logins folder
  5. Double click NT AUTHORITY\SYSTEM icon
  6. Click on the Server Roles icon in the Select a page pane
  7. Tick the sysadmin checkbox in the Server roles: pane
answered on Stack Overflow Nov 2, 2020 by Chameera

User contributions licensed under CC BY-SA 3.0