Reputation: 769
I have a scenario just like below:
I have a SQL Server Database and I do make operations to SQL server from my classic asp project. I needed to do some other stuffs into the same DB from another project which is written in ASP.NET C#. I did use a host address in connection string which was provided by hosting provider(Say, the host address is sqlxx.123xxx\inst_xyz). They also provided an IP with a port to connect the DB, which only works in SQL Server Management Studio. In the webconfig of C# project if I use the IP then it connects from my local dev machine. But it doesn't work after deploying to hosting.
Again, if I use sqlxx.123xxx\inst_xyz as host address in classic ASP then it works. The IP doesn't work here. My question is, host sqlxx.123xxx\inst_xyz works in classic ASP, IP works in ASP.NET C# in local IIS, but what will be the host for ASP.NET C# in hosting server ?
Please Note that, classic ASP project is in the main domain and ASP.NET C# project is in a sub domain of the main domain.
If I use either of the hosts(sqlxx.123xxx\inst_xyz or IP), I get an error which states exactly like below :
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)**
Upvotes: 0
Views: 303
Reputation: 856
Put this:
<add key="myCon" value="Server=this_my_host;database=dbname;User Id=myuser;Password=dbpass;"/>
and Remove <connectionStrings>
.
If you are connecting with your Remote host then you must use the <appSettings>
not the <connectionStrings>
string.
Upvotes: 1
Reputation: 9500
Try one of these two:
\
in the connection string, to \\
: "sqlxx.123xxx\\inst_xy"I'm thinking the backslash needs escaping.
Upvotes: 1