Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an issue with the connection string of my C# windows app.My database is in sql server 2005.I copied the db to a shared folder.I am using SQLHELPER class for sql functions.
The connection string is:
public static readonly string CONN_STRING=" Data Source=128.12.14.128,1433;Network Library=DBMSSOCN;Initial Catalog=db;User ID=sa;Password=sa123";

The db is in \\128.12.14.128\\NewFolder1\\db.mdf & db.ldf

Now when i tried to run my app, error shows:

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 - No connection could be made because the target machine actively refused it.)

Now can any one help me?
Posted

I think your hint is the "The server .... was not accessible." Make sure that your application has access read/write access to the share folder and that the user credentials being passed in have access to the db in question as well.
Use the site www.connectionstrings.com for more information.
 
Share this answer
 
v3
Comments
lilian87 10-Jan-12 11:18am    
How to make access to share folder? Help please!!
thatraja 10-Jan-12 13:37pm    
Right, 5!
lilian87 11-Jan-12 3:27am    
The credentials is not passed to the db.This is the problem. Thanks a lot!!.
Basically, when you failed to connect to your SQL Server, the issue could be:
1) Network issue,
2) SQL Server configuration issue.
3) Firewall issue,
4) Client driver issue,
5) Application configuration issue.
6) Authentication and logon issue.

Based on the error message you didn't allow the remote connection to that machine so change the options in settings.

Check these
Steps to troubleshoot SQL connectivity issues[^]
SQL Server 2005 Connectivity Issue Troubleshoot - Part I[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part II[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part III[^]

BTW check this bunch also for future errors
 
Share this answer
 
Comments
lilian87 11-Jan-12 3:26am    
The links you gave are superb!! Thanks for it. :) I didnt solved it, but found the mistake. The file cannot be accessed from SSMS. I tried using xp_cmdshell.Message coming as network name cannot be found.
Thanks again..
thatraja 11-Jan-12 5:16am    
I'm glad you solved the issue yourself. And I'm sorry I was off to bed that's why I couldn't reply you earlier.
You can't connect to a sql file across a network by default, you can only connect to a sql instance across a network.

http://g4ac.co.za/fu7WJ[^]

http://g4ac.co.za/1CHFX[^]

http://g4ac.co.za/kHuLH[^]
 
Share this answer
 
v2
Comments
lilian87 11-Jan-12 3:46am    
The links are so helpful.The problem is that in my network folder there is no sql server. So if I try to access also , it cannot be found.I liked the 3rd link more.:)
Thanks ..

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