2

I took an old software made by someone else, which need to connect to a database with the .mdf extension.

But when I run the software, I have an error 26. I have obviously checked Google and it seems the the main problem is the firewall. But if I disable it the problem doesn't dissapear.

Here is the code for connect the database :

DataClasses1DataContext db = new DataClasses1DataContext(Environment.CurrentDirectory + "\\bddgestionvin.mdf");

I've noticed, when I try to connect the database with the datacontext class it fail too with the same error 26. (see attached screenshot below)

The string connection used by this class is :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bddgestionvin.mdf;Integrated Security=True;Connect `Timeout=30;User Instance=True`

I know I'm a little vague but I never did that kind of stuff (connect to a .mdf database) And the code is not mine, feel free the ask further explanation / code. Any help is welcome !

P.S The error message is

SqlException was unhandled 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

enter image description here

(Sorry for the french software)

4
  • possible duplicate of Unable to connect to SQL Express "Error: 26-Error Locating Server/Instance Specified) Commented Oct 22, 2012 at 17:23
  • Is bddgestionvin.mdf in the execution app directory ? The sql connection says to auto attach mdf file in the app directory Commented Oct 22, 2012 at 17:24
  • Yes, he is in the bin/debug folder. And Yes I know there is plenty of topics about, but no one helped me, this is why I open a new topic Commented Oct 22, 2012 at 17:25
  • what's the issue getting? can you please update with message in engish. Commented Oct 22, 2012 at 17:35

1 Answer 1

1

Hi I don't know you may see these steps. Make sure that these steps should pass.

The reason that we get this error message is the client stack could not receive SSRP response UDP packet from SQL Browser. It's easy to isolate the issue. Here are the steps:

1) Make sure your server name is correct, e.g., no typo on the name.

2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts \ to . If you are not sure about your application, please try both Server\Instance and Server\Instance in your connection string]

3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).

4) Make sure SQL Browser service is running on the server.

5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.

You can read more from here

You can also try PortQry and validate your firewall does not block SQL Browser UDP packet

A network-related or instance-specific error occurred while establishing a connection to SQL Server. Failed to establish a connection with SQL Server.

The server was not found or was not accessible. May be server is stopped, you don't have permission to access the server, or the instance name is not correct .

Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

Please goto SSMS and try connecting the server. Verify the SQL Server is running and your account is configured to access the service.

(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Thanks

Sign up to request clarification or add additional context in comments.

6 Comments

I'm running this software in a local stored database, do I need too check all that DNS / server steps?
from that image I can see that your are using './SQLEXPRESS'. Normally it means that the server will be localhost and the instance name is SQLEXPRESS. Is it possible for you to connect the SQL Server using SSMS ?
I don't know if I can connect using SSMS, I will take a look and give you news about it
Do you have SQL server installed in your local machine ?. Start->Run -> SSMS. msdn.microsoft.com/en-us/library/ms189721.aspx
No, I don't have SQL Server, do I need to install it?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.