views:

37

answers:

1

I get this error when trying to connect to SQL Server.

Error is:

Login failed for user ''. The user is not associated with a trusted SQL Server connection.

Server resides remotely. From my localhost I am trying to connect using this URL:

"jdbc:sqlserver://serverName:portNo;integratedSecurity=true;databaseName=myDB"

But when I use the msSQL studio tool to connect to sql server doing windows authentication, it connects me without any error.

What is the difference in two cases?

Any help is appreciated.

Thanks

+1  A: 

This can happen if you have an extra space in your connection string. It looks like you've modified your example above to hide the server name — make sure that your actual connection string doesn't contain any spaces. See http://blogs.msdn.com/b/sql_protocols/archive/2005/09/28/474698.aspx

It can also happen if your web application is running under a different user — ie different to the one you're using to run SQL Server Management Studio. See http://blogs.msdn.com/b/sql_protocols/archive/2008/05/03/understanding-the-error-message-login-failed-for-user-the-user-is-not-associated-with-a-trusted-sql-server-connection.aspx

gutch
Where can I see what SQL Server Management Studio userid is using.Thanks
When you start up SQL Server Management Studio, the first thing you should see is the _Connect to Server_ window. When you're using Windows Authentication, the username should appear here automatically.
gutch