1

I have an c# app that tries to connect to a SQL Server that is in the same network but out of domain. I'm trying to use SqlConnection (I would prefer not use ODBC or ole db). My code is the follow:

con.ConnectionString =
"Server=PCX\\SQL;"+
"Initial Catalog=BBDD_SinGuid;"+
"User id=\\\\PCX\\user;"+
"Password=passwordofuser;";

And I'm sure that the user and the password are correct and are allow to connect to the SQL Server. The error that throws is a fail in the login with the user \PCX\user.

I'm missing something?

  • Check this: http://stackoverflow.com/questions/125341/how-do-you-do-impersonation-in-net/7250145#7250145 – Rahul Tripathi Oct 13 '15 at 15:14
  • Would it not cause fewer headaches to use a Sql Login if the server has mixed mode enabled? – SpaceBison Oct 13 '15 at 15:15
  • Yep, probably I will endly use a Sql Login. But thought that there would be any easy solution and that I was making some newbie mistake... – Quin Jon Wi Oct 13 '15 at 15:20
  • Have you tried connecting this database with management studio? Maybe you didnt allow remote connections. – HasanG Oct 14 '15 at 06:24

1 Answers1

0

you need to add trusted connectioon here..

Provider=SQLNCLI10;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes;

for more information you check below link it's has lot's of suggestion may be you will get your answer.

http://www.connectionstrings.com/sql-server-2008/

Javal Patel
  • 838
  • 7
  • 12