,Net Console App cannot connect to SQL server w/ correct credentials

I am writing a .Net console application.  Using MS SQL 2005 and .Net 4.  To connect to SQL I am using the SqlConnection class.  The code works just fine on my local machine against my local db.  However, when I change the connection string to point to a network SQL server, it throws an exception indicating that the login failed.  I know the credentials work against the db as they are the same credentials that many of our web apps are using and they have no problem.  I get the same result (against the remote SQL server) running the code either locally or on another server.  Can anyone shed some light on this?  
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Can you post a sanitized copy of your connection string?
amehanovAuthor Commented:
szConn = @"Server=xxxxx;Initial Catalog=Users;uid=domain\user;pwd=password";
käµfm³d 👽Commented:
Hmmm...  Was this paraphrased? I've understood passing a username and password in this manner (note User Id and Password):

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Anthony PerkinsCommented:
It cannot be uid=domain\user;pwd=password, that implies you are mixing Windows Authentication with SQL Server Authentication.

It is either standard:
Server=xxxxx;Database=Users;User ID=myUsername;Password=password;Trusted_Connection=False;

Or Trusted:
käµfm³d 👽Commented:
Disregard http:#35268023 . In browsing the MSDN, I see you can use either; www.connectionstrings.com didn't show it when I looked at it.
amehanovAuthor Commented:
So, just to be sure, I changed my connection string to:

szConn = @"Server=server;Database=Users;User ID=domain\user;Password=pwd;Trusted_Connection=False;";

Exact same result.  
Anthony PerkinsCommented:
>>Exact same result.   <<
As I stated you cannot do it that way.  You need to decide whether you want to use Windows Authentication or SQL Server Authentication.

Anthony PerkinsCommented:
So how about we ask this way:
Is the login you are trying to use was it setup using Windows Authentication or SQL Server Authentication?

amehanovAuthor Commented:
I read your post and II changed the connection string to the standard one (as per your specification in your post) when I last posted.   And it does not work.  I get the same result as the original connection string.  
Anthony PerkinsCommented:
Unfortunately, if you are using this:
szConn = @"Server=server;Database=Users;User ID=domain\user;Password=pwd;Trusted_Connection=False;";

Than this is not a login using SQL Server Authentication.
amehanovAuthor Commented:
That being the case, then if I understand you, I have to use the following connection string:


And if that is the case, the app will run under the credentials of who ever is logged in - and that means whoever wants to run this .exe must have their user account added to the db?  
Anthony PerkinsCommented:
>>and that means whoever wants to run this .exe must have their user account added to the db? <<
That is correct.  Regardless of how you connect to a database (SQL Server Authentication or Windows Authentication) that login is required to be added in the database in order for it to be accepted.
amehanovAuthor Commented:
Is there any way to configure the connection string to allow the app to log in as a particular domain user (so that any individual can use the app and not need their account added to the db)?  
Anthony PerkinsCommented:
No.  You will not be able to use Windows Authentication unless that user has that login or is a member of that Windows Group.  In either case, they will have to be added as a Login to SQL Server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.