简体   繁体   中英

SQL server remote access from and C# windows application

I have installed SQL Server 2008 R2 on my server and a C# application on Network Drive.

When I am running this application on server, it is working fine. But the problem occurs when I am running the application from client machines.

It does not connect to the server. I get the following error

Network related specific error..

Can anyone give me any solution ?

Connection string used:

<connectionStrings> 
    <add name="Truly_Paste_Solution.Win.Properties.Settings.TrulyDBAConnectionString" 
         connectionString="Data Source=.\sqlexpress;Initial Catalog=TrulyDB;Integrated Security=True;Pooling=False" 
         providerName="System.Data.SqlClient"/> 
</connectionStrings> 

What's your connection string ? Did you connect the SQL Server by IP ? Is there any firewall or Rules on your Server ?

Assuming your Server Lan IP address is 192.169.1.199 and your are running on MSSQL Server, so your connection string should be like :

Data Source=192.168.1.199;Initial Catalog=somedatabase;uid=yourid;pwd=yourpassword

Read about how to enable TCP/IP protocol connection here

There are different possible causes to get that kind of error -

  • Make sure your server's firewall settings allow remote host to connect
  • Make sure are connecting to the correct port of SQL Server which can be specified in the conecttiuon string
  • Make sure you have SQL or Mixed mode authentication enabled depending upon what scheme you use.

more things to check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM