Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I connect to database on server with this connection string.
SQL
Data Source=.;Initial Catalog=test;Integrated Security=true

How can I connect to this database from another computer on network? I use this connection string but it's not work.
SQL
Data Source=192.168.1.6\SQLEXPRESS;Initial Catalog=test;Integrated Security=true
Posted
Comments
Dave Kreskowiak 27-Apr-14 12:50pm    
Do you get an error message? What is it?
Is your SQL Server Express setup to accept remote connections?
Are your computers setup in a domain environment?
Is the user running the code on the remote machine trusted by the database?
[no name] 27-Apr-14 12:51pm    
Do you have an Windows user account on 192.168.1.6?

1 solution

In my experience, unless the application is on the same computer as the database, Integrated Security=true requires that the user be signed on with a domain account and not a local Windows account. Because your example includes a 192.168.*.* IP Address, I assume that you are not running in an environment where you are logged on with a domain account.

Therefore, instead of using Integrated Security=true, use Integrated Security=False;User id=xxxxx;Password=yyyy where xxxxx is a user id configured into the database server and yyyy is the password for user id xxxxx.

To enable SQL Server to use SQL Server Authentication and accept remote connections
In SQL Server Management Studio, right-click on the server name and click properties. In the Connections page, ensure that Allow remote connections to this server is checked. In the Security folder, click on SQL Server and Windows Authentication mode. Click the OK button. Restart the SQL Server service.

To create a SQL Server User Id
In SQL Server Management Studio, left-click on the Security folder under your server, then right-click Logins and left-click New Login. In the Login - New dialog window, check the SQL Server authentication radio button, enter a Login name and a Password in the appropriate textboxes, and uncheck the User must change password at next login checkbox. Click OK.
 
Share this answer
 
v4

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