Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

c# - How to run desktop application using SQL Server database on other computer connected with LAN

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...