0

I am having an issue trying to create a window's service that will perform some work after communicating with a sql server database. The server is the default local one created through visual studio 2012. The error that I routinely receive is: Cannot open database "databasename" requested by the login. The login failed.\r\nLogin failed for user 'NT AUTHORITY\SYSTEM. I've read through numerous posts on similar issues. I think the closest ones are here:

Login failed. Login failed for user 'NT AUTHORITY\SYSTEM'

SQL Server Login error: Login failed for user 'NT AUTHORITY\SYSTEM'

As suggested in this and similar posts, I went into Sql Server Management and created a login for NT Authority \ System that included ownership/admin privileges for the appropriate database. The amazing thing is this worked...once. I can, on occasion, get the service to communicate with the database, but 95% of the time, it still fails with that error. I've tried everything from related threads. Following the same steps, I'm also unable to get the service to talk to our real server outside of the development environment setup.

On the majority of cases where it fails, the SQL error log indicates: "The prelogin packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library. [CLIENT: ]" with Error: 17828, Severity: 20, State: 3. I've looked into this as well. Various google searches suggest this is due to trial server installs and that clearing out some random folder or increasing MaxTokenSize will help. Neither has had any effect.

After several days, I'm out of ideas. Any help would be appreciated.

Community
  • 1
  • 1
  • Have you tried running your service with a different login than `NT AUTHORITY\SYSTEM`? – Dave Mason Nov 18 '14 at 16:14
  • Insofar as I've tried specifying a user id in the connection string, yes. I tried the default user admin account. Same behavior. Works once in a while, but mostly throws the same error. – ConfusedStatGuy Nov 18 '14 at 18:43

0 Answers0