1

I'm just publishing my website to my domain name and when I try to access it in my browser I get the Following error:

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)

I think the problem is into my connection String ==>

<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="TennisOnlineContext" connectionString="Data Source=|DataDirectory|Tennis.sdf" providerName="System.Data.SqlServerCe.4.0 " />
</connectionStrings>
...
</configuration>

Sorry but it's my first web site where I try to publish... So, please what I'm doing wrong ? Thanks in advance...

Neil Knight
  • 47,437
  • 25
  • 129
  • 188
Razor
  • 1,385
  • 4
  • 18
  • 28
  • 3
    Does `SQLEXPRESS` exist on your domain? – Neil Knight Mar 28 '12 at 15:58
  • Thank you for your response, but How can I verify that ? Sorry, I'm beginner in web development :( – Razor Mar 28 '12 at 16:00
  • Does your Web hosting come with a SQL Server Instance? Does your Web hosting support SQL Server? – Neil Knight Mar 28 '12 at 16:16
  • Yes, I'm using "Combell" http://www.combell.com/en/shared-webspace/windows-hosting – Razor Mar 28 '12 at 16:20
  • Possible duplicate: http://stackoverflow.com/questions/2124457/visual-studio-2008-c-with-sql-compact-edition-database-error-26 http://stackoverflow.com/questions/5724469/how-can-i-connect-to-a-sdf-database-no-connection-string-i-try-seems-to-work – Andrew Savinykh Apr 02 '12 at 01:23

5 Answers5

4

If you are connecting from Windows machine A to Windows machine B (server with SQL Server installed), and are getting this error, you need to do the following:

On machine B:

1.) turn on the Windows service called "SQL Server Browser" and start the service

2.) in the Windows firewall, enable incoming port UDP 1434 (in case SQL Server Management Studio on machine A is connecting or a program on machine A is connecting)

3.) in the Windows firewall, enable incoming port TCP 1433 (in case there is a telnet connection)

4.) in SQL Server Configuration Manager, enable TCP/IP protocol for port 1433

enter image description here

JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
4

Have you tried localhost\SQLEXPRESS? Ensure all of your connection keywords abide by those outlined by Microsoft here.

You can check if a connection string is valid, or indeed build a valid connection string that you can copy, by using the SQL/Database Connection utility that ships with VS2010. In VS2010 goto Tools, Connect to database. This will launch the connection dialog; here you can build and test connection strings. For advance connection features, once in the dialog click Advanced. From the advance dialog you can copy and paste connection strings.

Microsoft have also released this dialog to be freely used and distributed in .NET applications. If you interested in this it can be found here.

I hope this helps.

MoonKnight
  • 23,214
  • 40
  • 145
  • 277
  • Thanks for response, the type of my database is SQL Server Compact 4.0, and the connection string in the advanced dialog is: Data Source="C:\Users\My Name\Desktop\Projet Tennis\share\Projet Tennis\tennisonline\TennisOnline\TennisOnline\App_Data\Tennis.sdf" – Razor Mar 28 '12 at 16:18
  • You need to select the required server instance from the list of avalible servers; set you desired options and then test the connection. If it works, great! Copy it, and use in your code (temporarily - as this is not sufficent for your release version, ofcourse). – MoonKnight Mar 28 '12 at 17:23
0

please check once TCP/IP properties in SQL server configuration manager

for more details here

0

Enable TCP/IP and Named Pipes in SQL Server Configuration Manager.

From SQL Server Configuration Manager, select SQL Server Network Configuration, then select the appropriate instance (if you have multiple). Right click and select enable for Named Pipes and TCP/IP.

ScottLenart
  • 1,160
  • 1
  • 12
  • 15
0

If you look into your release version of web.config you will find <roleManager enabled="false"
Change this configuration setting to True You can find details here at this link below http://dotnet1blogger.blogspot.com/2012/04/network-related-or-instance-specific.html

Lee
  • 665
  • 3
  • 7
  • 16