Reputation: 21
I need to access database in another computer using c#...I am using connection string with IP address for accessing database and also changed firewall setting but it shows error as follows
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
I m using this connection string
SqlConnection con = new SqlConnection("data source=192.168.1.12,1063;initial catalog=trinity;integrated security=false;network library=DBMSSOCN");
Upvotes: 2
Views: 5447
Reputation: 5039
This is actually quite a large topic involving: Networking, Authentication, Authorization and Permissions. Quick checklist:
In your connection string you have Integrated security=false;
, so you need to provide User ID=mysqlserveruserid;Password=mysqlserverpassword;
parameters in your connection string instead. If you change Integrated security=true;
your Windows credentials will be used.
Also why the IP Address? Do you not have network name resolution on your network? e.g. DNS or WINS.
Is SQL Server running as the default instance or does it have a named instance? If it's a named instance (would have been a choice taken when installing SQL Server) You will need Data source=computername\sqlserverinstancename;
More detailed information on all these aspects can be found on MSDN https://msdn.microsoft.com/en-us/library/ms345332.aspx
Upvotes: 1