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)

Community
  • 1
  • 1
Edelweiss
  • 621
  • 1
  • 9
  • 24
  • possible duplicate of [Unable to connect to SQL Express "Error: 26-Error Locating Server/Instance Specified)](http://stackoverflow.com/questions/6466974/unable-to-connect-to-sql-express-error-26-error-locating-server-instance-speci) – Mike Perrenoud Oct 22 '12 at 17:23
  • Is bddgestionvin.mdf in the execution app directory ? The sql connection says to auto attach mdf file in the app directory – Mohsen Afshin Oct 22 '12 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 – Edelweiss Oct 22 '12 at 17:25
  • what's the issue getting? can you please update with message in engish. – kbvishnu Oct 22 '12 at 17:35

1 Answers1

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

kbvishnu
  • 14,760
  • 19
  • 71
  • 101
  • I'm running this software in a local stored database, do I need too check all that DNS / server steps? – Edelweiss Oct 22 '12 at 17:45
  • 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 ? – kbvishnu Oct 22 '12 at 17:49
  • I don't know if I can connect using SSMS, I will take a look and give you news about it – Edelweiss Oct 22 '12 at 17:55
  • Do you have SQL server installed in your local machine ?. Start->Run -> SSMS. http://msdn.microsoft.com/en-us/library/ms189721.aspx – kbvishnu Oct 22 '12 at 17:57
  • No, I don't have SQL Server, do I need to install it? – Edelweiss Oct 22 '12 at 18:11
  • As per the picture, you are trying to connect a database server installed in your machine with the corresponding sql instance name `SQLEXPRESS`. I think you required sql server. – kbvishnu Oct 22 '12 at 18:13