3

I created a windows form application which is connected with a local sql server database. The sql server is windows authenticated.

Now I want to run same application on another computer which is connected to this computer via LAN. I just wanted to know the step by step process that allows to access my windows authenticated database on another computer.

Filburt
  • 17,626
  • 12
  • 64
  • 115
yash
  • 812
  • 3
  • 12
  • 37
  • 1
    Why does he need WCF or web API to connect another PC to a SQL Instance on the same LAN? – Matt Mar 28 '14 at 14:32

2 Answers2

6

By default Remote connections in SQL Server Express is turned off.

Just turn on the remote connections for SQL Express, enable TCPIP protocal and restart the service, check errorlog whether it's listening on all network adapters Now try to connect using the machine name (since it's dynamic) from the client pc

here is a step

  • Open SQL Server Configuration Manager
  • Select SQL Server Network Configuration
  • Chose your instance of SQL Server
  • Make sure that TCP/IP protocol is enabled
  • Right click TCP/IP protocol
  • Select properties
  • Click IP addresses tab
  • Scroll down to IP4. The IP address of the server should be here. Set active to yes and enabled to yes. Set TCP port to 1433 (don't know if this is necessary. Can some expert comment)
  • Scroll down to IPAll. Set TCP port to 1433
  • Make an inbound firewall rule for port 1433
  • open sql server management studio, right click server instance, properties->connections-> allow remote connections. Security-> SQL Server and Windows Authentication mode
  • restart sql server service
  • restart sql server browser

now use sql connection string COMPUTERNAME for E.g

data source=COMPUTERNAME;database=databasename;user id=sa;password=pass;" providerName="System.Data.SqlClient"

Another reference link ..http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx

Anant Dabhi
  • 10,864
  • 3
  • 31
  • 49
1

I hope you have sql server authentication as well. If two of your computer are not in same domain, you need to use sql server authentication to connect from other computer.

Follow the step described by Anant Dabhi to turn on Surface area configuration. Now, you also need to change your connectionstring. Replace localhost or . in your current connection string by IP or computer name of the Machine where sql server is installed.

Yauvaraj Rimal
  • 620
  • 5
  • 22