I have an ASP.NET application using Entity Framework. I'm trying to release it on the hosting, but I get following errors:
[Win32Exception (0x80004005): The system cannot find the file specified]
[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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I set the connection string as shown on the hosting website and created database. How should I configure this to get rid of this error?
Exception due to your web application is not able to connect SQLSERVER instance. Following are options to resolve the problem:
Check if your service is running up
Go to All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
Check to make sure SQL Server service status is Running.
or
Open run command console(Windows + R) then type services.msc. You will all services in your system and check SqlServer (Sqlexpress) service is running mode.
Make sure your database engine is configured to accept remote connections
Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance using services.msc in run command window(discussed in #1)
Enable TCP/IP in SQL Server Configuration
Go to All Programs >> Microsoft SQL Server 2012 > Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
Right Click on TCP/IP >> Click on Enable
Then restart the sqlserver service using services.msc in run command window(discussed in #1)
Lastly you need to check that it might be server firewall setting because sometimes firewall blocks incoming request from other servers. And also check you are providing correct connection string means username, password, server etc.
Thank You..
<connectionStrings>
<add name="conn2" connectionString="Data Source=192.?.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
</connectionStrings>
As you are able to connect from SQL SMS, try to connect with the same remote parameters from Server Explorer window in Visual Studio as well. Click "add connection" on "Data Connections": Add Connection in Server Explorer. After the connection being created, get the connection string from the properties window by right clicking on the connection object. Use this connection string in the hosted web.config file.
Related
I'm working on a tool that uses an SQL Server as a database.
First I was using Visual Studio's localdb, then I was using an Azure SQL Server, both of which worked just fine.
I now tried to host my own SQL Server Express, but I can't seem to connect to it. It's hosted in an Azure VM, I have restarted it, enabled TCP and I have opened Port 1433 in Azure.
I have tried both connecting remotely, running the web-app on my local computer and connecting to tcp:{IP}\InstanceName, as well as running the app on an IIS Server on my VM using .\InstanceName in the connection string (although I still get told to check if the server is set up correctly to handle TCP ? )
Connecting locally on the VM, using Microsoft SQL Server Management Studio works though, so I suspect the connection string in my web.config must be wrong ...
It looks like this:
<connectionStrings>
<add name="defaultConnection"
connectionString="Server=tcp:12.345.678.910\InstanceName,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password={mypassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
providerName="System.Data.SqlClient" />
</connectionStrings>
The error message I get is:
Server Error in '/application-name' Application. The remote computer refused the network connection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The remote computer refused the network connection
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: [Win32Exception (0x80004005): The remote computer refused
the network connection]
[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 - The remote computer refused the network connection.)]
(and more but it doesn't seem important - will post if necessary or helpful)
Any idea what I'm doing wrong?
Found the solution on my own:
It's not enough to enable TCP in the Server Configuration Manager, you also have to SQL Server Network Configuration > Protocols for X > TCP > Properties > IP Adresses and set TCP Port to 1433 under IPAll.
SQL Server Express doesn't allow remote connections - by default.
You need to explicitly enable remote connections - easiest way is to use SQL Server Management Studio, connect to it, and then in "Object Explorer" right-click on the server icon, and pick "Properties".
In the dialog that shows up, make sure to tick the "Allow remote connections to this server" checkbox:
I created a web application that it should run in local and I don't need to transfer it to host, but when I try to run my web application on local I get this 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
Other projects that use SQL Server 2008 R2 run without any problem but this project that uses SQL Server Express shows this error.
Go to
Start Menu >
Microsoft SQL Server 2008 R2 >
Configuration Tools >
SQL Server Configuration Manager
You should see a screen something like this:
If you have two instances running, there should be two entries on the right with "SQL Server (....)" and State = running. The values in the brackets is the instance name for each - what are does??
MSSQLSERVER stands for the default, unnamed instance - you connect to it using ., (local) or the machine name alone
SQLEXPRESS is the default for a SQL Server Express installation, and you connect to it using .\SQLEXPRESS, (local)\SQLEXPRESS or your-machine-name\SQLEXPRESS
If the instance name is anything else - that is your instance name which you need to use after the colon (.) or the (local) to connect to it locally
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.
when i created user by CreateUserWizard control ASPNETDB.MDF Automatically added in App_Data Folder, then i cant open & show ASPNETDB.MDF , Error dialog box appear and tel my :
the attempt to attach to the database failed with the following information: 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. unexpected error occurred inside a localdb instance api method call. see the windows application event log for error details. )
Firstly,
Make sure your database engine is configured to accept remote connections
• Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration • Click on Surface Area Configuration for Services and Connections • Select the instance that is having a problem > Database Engine > Remote Connections • Enable local and remote connections • Restart instance - See more at: http://www.sswug.org/articlesection/default.aspx?TargetID=44331#sthash.kzSfADZL.dpuf
Secondly,
You may need to create an exception on the firewall for the SQL Server instance and port you are using • Start > Run > Firewall.cpl • Click on exceptions tab • Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn, check your installs for the actual folder path), and port (default is 1433) • Check your connection string as well - See more at: http://www.sswug.org/articlesection/default.aspx?TargetID=44331#sthash.kzSfADZL.dpuf
Thirdly Check if your SQL server services is up and running properly
Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services, and check if SQL Server service status is “Running”.
In addition, ensure that your remote server is in the same network. Run “sqlcmd -L” in your command prompt to ascertain if your server is included in your network list. You can even find tutorial for the same here SQL SERVER – Find All Servers From Local Network – Using sqlcmd – Detect Installed SQL Server on Network.
Next Enable TCP/IP in SQL Server Configuration
Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP. Right click and select enable
Lastly Go to your firewall setting, under exception tab, select add port include TCP:1433 and tick the SQL check box.
All these did helped me and several of my lab mates whom have trouble connecting to the remote server
References : http://www.sswug.org/articlesection/default.aspx?TargetID=44331 http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
Source: Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?
Hi i want to publish my application in a IIS server.
First i create a database in my sql server and put all my needed data on it.
Then i update my web.config to use the new remote Database. Unfortunatly i get an error
ConnectionString:
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=IntranetDatabase;Data Source=SRVDEV2010\SRVDEV2010" />
Stacktrace :
[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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I cheked if i can access database remotly. I create a udlfile to verify my connectionstring, Here is the result.
I don't know why the udl file can connect but not my application. Any help is appreciated
Under which user is the Application Pool configured to run? you're using Windows Authentication which means your IIS App pool should be configured to run under a user that has access to the DB.