I'm currently setting up a remote SQL Server. Made all steps regarding remote connection (as found on http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/).
Let's say my servers are :
WEB
SQL
I can connect from WEB, using SQL Server Management Studio, to my SQL Server using my connection string. Using the same connection string in my web.config does not work, keep getting error 26 - Error locating server.
Connection string:
Data Source=169.254.196.1,1433;Initial Catalog=MyDb;User ID=myuser;Password=mypassword
Any ideas?
Related
Tech used:
Visual Studio 2015
ASP.NET 5 MVC 6 RC1
Identity via EF 7
I've successfully made a connection to a remote MSSQL server using the Server Explorer UI within VS2015. When I say "remote", I mean not on the same machine as my dev machine, but a machine that is local to the network.
Here is the connection string, which is the same in the Server Explorer (works) and the appsettings.json (doesn't work):
"Data Source=DBSERVER\INSTANCE1;Initial Catalog=MyDb;User ID=ASPNET-Db-User;Password=thepassword"
I'm using SQL Authentication in both cases.
When I copy the connection string from the server explorer and plug it into appsettings.json and try to connect to the db in order to create an Identity user account via the "register account" view, I get a connection error:
SqlException: 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)"
It seems that, clearly, the SQL instance is reachable, but somehow ASP.NET isn't able to connect to it.
Any idea how I might trouble shoot this?
I tried the same code in MVC5 and everything works as expected. I believe this to be a MVC 6 error and have opened a bug report at
https://github.com/dotnet/corefx/issues/4586
After chatting with the folks building MVC 6, it turns out that the CoreCLR does not support named pipes. Using a fully qualified address and an explicit port sorts the problem.
I have a web forms application that is connecting to a SQL Server 2012 database. When I try to open the connection within the app I get this error:
System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) ---> ...
I've checked and SQL server is configured to allow remote connections, TCP/IP is enabled, the server is up and I can connect to it via SSMS and Linqpad.
This is occurring when I run the application locally, hitting a local database. I know the connection string works, as I can use the login in SSMS to login and I have a linqpad query that is working with no problem using the same connection string. Also the error occurs when I try to open the connection (i.e. the connection is created successfully).
I'm guessing there is some access/security issues with my configuration of IIS, but I not finding it.
After a couple of frustrating days, I discovered the solution. The problem was that SQL server wasn't setup to use TCP/IP. This is configured in the Sql Server Configuration Manager, under the SQL Serer Network Configuration node, then Protocols for MSSQLSERVER. Make sure TCP/IP is enabled.
I developed an ASP.NET web application and it worked fine locally with IIS express.
I created deployment package and installed the application on my Windows 2012 server.
When developing the application, I was using an mdf file with localdb v11.0. On the server, however, I wanted to use sqlserver express. I changed the connection string to
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\nameoffile.mdf;Integrated Security=True;Connect Timeout=30
After making this change I was able to connect to the application from another host on the network. Viewing data and using filters/search (built into stored procedures) works fine.
The error occurs when I try to insert new records or delete records. The message is:
Server Error in '/Nameofapplication' Application.
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: 50 - Local Database Runtime error occurred.
Cannot create an automatic instance. See the Windows Application event
log for error details. )
I've turned off the firewall, allowed remote connections, started sql server browser and agent and various other solutions that I've found from googling without any luck.
Any ideas about how to solve this issue?
I have a web app that I developed using Visual Web Developer 2010. The database is local inside the solution:
<add name="SFDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SFDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
I'm trying to run the app on another machine using Visual Studio 2010 instead of the web developer and it's giving me the following error when it tries to connect to the database:
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)
Does anybody has any idea on what could be happening?
Usually, this error message means exactly what it says...
Can you connect to the SQL server through UI client (like, management studio)? If yes - how do you do that (user/password or Windows authentication; what is the server name)?
What is the connection string? You put here the connection string to SQL Express (which works; so it isn't quite helpful) - but forgot to put the connection string that doesn't work.
If you can connect in UI, and connection string is correct - there is no reason why the code would throw an error!
I'm using Visual Web Developer 2010 Express on my laptop to run some ASP.Net which is trying to access an Oracle database on another machine.
I've having some difficulties executing ...
SqlConnection myConnectionTest = new SqlConnection(s);
... and before I went any further I thought I should check .... does VWD2010 impose some sort of limitations on accessing remote databases ?
[Not sure if this is relevant the connectionStrings entry to oracle is using a TNS-less connection string like this :
<add name="ABC" connectionString="providerName="OraOLEDB.Oracle";Data Source=//foo.bar.com:1521/dev10.foo.bar.com;User Id=auserid;Password=apwd;"/>
There are no limitations that would prevent access to an Oracle Database
What is "missing" in the Visual Studio 2008 Express Editions?
This may be of some value:
Tips on Oracle Connection Strings
Mitch Wheat
Interesting point about the provider aspect of the connection string. If I don't put it into the string so that the connection string looks like this ...
<add name="ABC" providerName="OraOLEDB.Oracle" connectionString="Data Source=//foo.bar.com:1521/dev10.foo.bar.com;User Id=auserid;Password=apwd;"/>
... then I get an error which suggests that VWDC is trying to connect to a SQL Server database !
Ex.Message = 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: 25 - Connection string is not valid)
... the way that it seems to be defaulting to SQL Server which was what made me wonder initially whether there was some lim itation within VWDC.
Any comments on this welcome !
According to connectionstrings.com, a TSN-less connection string has the form:
Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=myPort)))(CONNECT_DATA=(SID=MyOracleSID)(SERVER=DEDICATED)));User Id=myUsername;Password=myPassword;
Is 'providerName' also accepted?