hello every one
I made setup for an application containing database built by sql server express edition

I made the connection string dynamically taken from
Application.StartupPath

but when trying to install it on a different PC , i got the following exception..

an error has occured while establishing a connection to the server
when connecting to sql server 2005 the failure may be caused by the fact thatunder the default settings sql server does not allow remote connections(provider:sql network interfaces error:26-error locating server/instance specified)

any ideas .?
thanks in advance

Dani AI

Generated

Short refresher tailored to this thread: the "error locating server/instance specified" (error 26) means the client cannot resolve or reach the SQL Server instance you pointed to. As noted, Express requires explicit configuration for remote access; already pointed toward the Microsoft guidance. Common causes are the instance/service not running, network protocols disabled, SQL Server Browser not running (for named instances), Windows firewall blocking the port, or a connection string that tries to attach a local MDF (built with Application.StartupPath) instead of addressing an attached database on the server.

Quick checklist to resolve it:

  • On the machine hosting SQL Server: confirm the SQL Server service for that instance is running and enable TCP/IP (and named pipes if needed) in SQL Server Configuration Manager. If you use a named instance either start SQL Server Browser or assign a static TCP port to the instance.
  • Firewall: allow incoming TCP on the instance port (default 1433 for a default instance). For named-instance discovery either allow UDP 1434 or use a static port and specify it in the client string.
  • Avoid relying on AttachDbFilename to files inside the app folder on client machines. Attaching should be done on the server instance during install; user-instance/auto-attach behavior is fragile and often fails on deployed systems (permissions, virtual store, user instances).
  • Create a specific low-privilege SQL login for your app rather than shipping SA credentials.

Example connection strings you can test from the client (replace names/IPs/credentials):

Data Source=ServerName\InstanceName;Initial Catalog=MyDatabase;Integrated Security=True;
Data Source=192.168.1.100,1433;Initial Catalog=MyDatabase;User ID=appuser;Password=yourStrongPassword;

Testing tips and final notes: try connecting from the client with SQL Server Management Studio or sqlcmd to confirm reachability; check the SQL Server error log and Windows Event Viewer for startup/protocol errors; use the server logs to confirm which port the instance listens on. For installers, attach the DB to the instance as part of setup or deploy to a central SQL instance rather than shipping an MDF with the application.

Recommended Answers

All 2 Replies

I read somewhere (maybe even on this site!) that express editions don't allow remote connections.

How to configure SQL Server 2005 to allow remote connections

By default the express editions of MSSQL don't enable remote connections. You can enable it after installation or specify to allow remote connections at installation time:

setup.exe /qb ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,Client_Components,Connectivity,SQL_SSMSEE INSTANCENAME=InstanceName SAVESYSDB=1 SQLBROWSERAUTOSTART=1 SQLAUTOSTART=1 AGTAUTOSTART=1 SECURITYMODE=SQL SAPWD=password DISABLENETWORKPROTOCOLS=0 ERRORREPORTING=1 SQMREPORTING=0 ADDUSERASADMIN=1 INSTALLSQLDIR="%ProgramFiles%\Microsoft SQL Server\"
commented: sql express enable remote connections?--this guy knows everything!!! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.