Answered by:
Connection string not working when moved from IISExpress to IIS

Question
-
User-892296104 posted
My connection string was working fine when using IIS Express. Now after moving to IIS. I'm getting error as
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: Named Pipes Provider, error: 40 - Could not open
a connection to SQL Server)Not able to figure out the reason for this.
please suggest
Tuesday, February 18, 2014 2:11 PM
Answers
-
User-1454326058 posted
Hi kiranmayi,
Please try to use the connectionString like this:
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Thanks
Best Regards
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 19, 2014 10:40 PM
All replies
-
User1873438307 posted
Hello,
You cannot use SqlExpress db in your hosting account. You have to create db through your hosting account (server) and to connect into that after deploying the database.
For connectionstrings reference check the following URL:
Tuesday, February 18, 2014 2:55 PM -
User-892296104 posted
I'm using SQL Server 2005 not SQLExpress. The database is on a remote server.
Tuesday, February 18, 2014 6:26 PM -
User-1454326058 posted
Hi kiranmayi,
According to your description, I would like to know do the IIS Express and IIS in the same machine.
Please provide your connectionstring.
On the other hand, please refer to this link: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c488cf76-2515-440f-b3f8-9cfad689c5b6/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server?forum=sqldataaccess
Thanks
Best Regards
Wednesday, February 19, 2014 2:34 AM -
User-892296104 posted
yes both IIS and IISExpress are on the same machine.
<add name="myConnectionString" connectionString="Persist Security Info=False;User ID=userid;Password=password;Initial Catalog=mydatabase;Data Source=myserver"/>
I tried with IP address also.
Wednesday, February 19, 2014 3:01 PM -
User-1454326058 posted
Hi kiranmayi,
Please try to use the connectionString like this:
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Thanks
Best Regards
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 19, 2014 10:40 PM -
User649579883 posted
Please check that your SQL server is allowing TCP/IP and port is correct.
You can use connection string like
<add name="userDbConnectionString" connectionString="Data Source=XXX.XXX.XXX.XXX;Initial Catalog=YourDB;user id= sa; password =sa" providerName="System.Data.SqlClient"/>Wednesday, February 19, 2014 11:09 PM -
User13850534 posted
Since your database is on live production server, you should check if your hosting server is blocking the connection. Maybe you have to contact hosting support for assistance.
Thursday, February 20, 2014 8:55 PM