Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hi;

I have a C# program that connects the sql server database.
I can connect this database with this connection string on my computer;
"Data Source= DESKTOP-E0NKE43\\MYINSTANCE; Database= MYDB; Integrated Security= True;"

But when I put this program to another PC, I cannot connect with this connection string.

My sql server instance is visible to other computers, so what can I do?


Thanks.

P.S: The PC that I'm trying to connect is in the same network on sql server.
P.S1: I haven't try to create a new login user on sql server yet, because I assume Windows Authentication is fine for local computers.

What I have tried:

I enabled the sql server to allow incoming requests. And I'm very sure that sql server instance is visible from other computers because my program checks and list all available sql server instances. I check that using PowerShell too.
I tried the change my connection string Data Source with my computer name, my IP address etc.
Posted
Updated 20-Sep-17 19:46pm
Comments
Richard MacCutchan 20-Sep-17 11:48am    
What error do you see?
Onur ERYILMAZ 20-Sep-17 12:36pm    
sqlconnection opening error.

1 solution

"Integrated security" is probably your problem, if the DB is still on the same PC as it was - the user on the "new" machine probably isn't authorised to access your computer.

You shouldn't really use integrate security in production anyway - using SQL authentication allows you to select an SQL user (which is not the same as a PC user) that has just sufficient privileges to do the job your app needs, and no more - which can help to protect your DB.

Have a look here: Simple SQL Connection String Creation[^] - it may help you generate a string that will work.
 
Share this answer
 
Comments
Onur ERYILMAZ 21-Sep-17 5:12am    
Thank you for your answer OriginalGriff.

I have managed to connect by using Username and Password like you said. I can continue with that.

But I can't figured it out why I can't connect the database via Windows Authentication. I mean I am I missing?
OriginalGriff 21-Sep-17 6:02am    
Windows authentication isn't a "miracle cure" - it just says "use the credentials for the user of this machine to access that one". If the user has no rights - and he doesn't by default for damn good reasons - then he gets no access.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900