Question Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server con

ProtelAs

New member
Joined
Jun 12, 2012
Messages
3
Programming Experience
1-3
Hi,

I am trying to run a logIn form application using MS Visual Studio 10, running on windows 7. When trying to open connection with SQL server 2005, i get an error. My connection is as follows:

Data Source=XXX;Initial Catalog=XXX;Integrated Security=True

and the following error appears:

System.Data.SqlClient.SqlException was unhandled
Class=14
ErrorCode=-2146232060
LineNumber=0
Message=Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Number=18452
Procedure=""
Server=XXXXX
Source=.Net SqlClient Data Provider
State=1
 
You are trying to login to the SQL Server instance as the current Windows user but that user is not known by that instance. Is the instance local or on another machine? If it's on another machine, are the two machines both part of a domain?
 
Well the SQL server is on another machine, but i don't know if both machines are part of a domain, my machine is part of a workgroup.


You are trying to login to the SQL Server instance as the current Windows user but that user is not known by that instance. Is the instance local or on another machine? If it's on another machine, are the two machines both part of a domain?
 
If they're in a workgroup then they're not in a domain. As such, there's no central repository for user accounts. That means that each machine has its own set of users, so the machine with SQL Server doesn't know anything about the user logged into Windows on your machine. Basically, you can't use integrated security to connect to an instance on a different machine in a workgroup.
 
OK now i understand your point, but now what is the solution? How can I make both machines part of the same domain so that integrated security can be used.

I was trying to run an application using visual studio 10 and changed the project settings to "Use SQL server authentication" instead of "Use windows authentication" and provided the server username and password, so I was able to run the application.

But there is another application where i only have the application files without out the project or source files, and the same error appears when i run it, so do I need to make my machine and the server machine on the same domain in order to run it?

If they're in a workgroup then they're not in a domain. As such, there's no central repository for user accounts. That means that each machine has its own set of users, so the machine with SQL Server doesn't know anything about the user logged into Windows on your machine. Basically, you can't use integrated security to connect to an instance on a different machine in a workgroup.
 
You can't make the machines part of a domain unless you have a domain controller, which basically means dedicated machine running Windows Server and then all your user accounts stored in Active Directory. If you didn't know that already then that's unlikely to be a realistic option, which is why home networks are always workgroups rather than domains. With domains you have a central repository for account information and all machines on the domain access that. With workgroups, you create accounts on each machine with the same user name and password so that you are able to behave as though they are the same account under some circumstances. I think that that should work with SQL Server too. So, you need to create an account on the SQL Server machine with the same user name and password as the account you're logging onto the client machine with and make sure that that account has appropriate permissions to SQL Server.
 
Back
Top