win2008 R2 Install SQL Server 2005/2008 cannot connect to server resolution _MSSQL

Source: Internet
Author: User
Tags stack trace management studio sql server management sql server management studio connectionstrings

A network-related or instance-specific error occurred while establishing a connection with SQL Server. The server was not found or could not be accessed. Please verify that the instance name is correct and that SQL Server is configured to allow remote connections.

When using the G2 service, the test server connection results in this problem.


Problem Detail: Connection Test failed! : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or could not be accessed. Please verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named pipe provider, error:40-cannot open a connection to SQL Server).

Native configuration: Win7 system, SQL Server 2008 R2 database, test database connection using G2 service in 360 browser test.

First look at the database has allowed remote connections, the database connection string is also filled in correctly. PS: Connect friend database normal.

Searched the internet for some answers.

One of the first methods:

Run enter Services.msc to see if the SQL service is all open.


Start all SQL-related services that can be started and the problem is still unresolved.


The second method:

Set up TCP/IP in Configuration Manager with Port set to default 1433.


After the result SQLEXPRESS protocol was set to 1433, there was an error in restarting SQL Server (SQLEXPRESS).


And then you can't start again.


Finally found a good friend to help, finally solved the problem.

The settings you make are:

Change SQL Server (SQLEXPRESS) TCP/IP


8099 of these are any set ports (followed by the firewall settings).

You can then start SQL Server (SQLEXPRESS)


Open the Firewall in Control Panel and click Advanced Settings.

Click on the inbound rule to create a new rule


Select Port, Next


Enter the previous port 8099, next


Allow connections by default, next


Default, Next


Enter the name 8099 (optionally named), complete.


Back to the Advanced settings interface


Database Test Successful


Your support is my inexhaustible motivation. If there is a wrong place, please correct me.

A network-related or instance-specific error occurred while establishing a connection with SQL Server. The server was not found or could not be accessed. Please verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named pipe provider, error:40-cannot open a connection to SQL Server)
Note: An unhandled exception occurred during the execution of the current WEB request. Check the stack trace for more information about the error and where the error occurred in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection with SQL Server. The server was not found or could not be accessed. Please verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named pipe provider, error:40-cannot open a connection to SQL Server)


When this problem occurs, it is very simple, is a different version of the database, to connect the same method; note the following Scarlet Letter section. I used to use server=. DATABASE=JTJ; User Id=sa; password=


Changed into the server==.//sqlexpress;initial CATALOG=JTJ; User Id=sa; password=


It's been a long time.

1. Open the Sql2005 remote connection function, the opening method is as follows:
The Configuration tool->sql the server perimeter configuration-> service and the perimeter configuration of the connection-> open the Database engine node under the MSSQLSERVER node, select Remote Connection, and then recommend "use tcp/simultaneously" IP and Named pipes ", and then restart the database service after you are OK.

2. The login settings should read: SQL Server and Windows authentication mode, as set out below:
SQL Server Management Studio Manager->windows Authentication connection Server-> Object Explorer Select your data server-> Right-click-> Properties-> Security->sql Server and Windows authentication mode is selected.
3. Set a user name and password in SQL Server mode, as set out below:
(1) SQL Server Management Studio Manager->windows Authentication connection Server-> Object Explorer Select your data server-> expand Security on the server-> login name-> Right-click-> on the sa account to select General-> to change the password for the sa login account. This sets a user named SA with the password: sa123456.
(2) "Select Page" SELECT Status-> login modified to enable
4. Database connection string
There are several kinds of database connection strings, I believe you've seen them, they're all messed up.
Data server=./sqlexpress;initial Catalog=northwind; User Id=sa; password=sa123456
Data server= server name/sqlexpress;initial catalog=northwind; User Id=sa; password=sa123456
Data server=localhost/sqlexpress;initial Catalog=northwind; User Id=sa; password=sa123456
Data Server=.;i Nitial Catalog=northwind; User Id=sa; password=sa123456
Data server= server name; Initial catalog=northwind; User Id=sa; password=sa123456
......
What exactly is that right? This is related to the database version, and if it is the SQL Server version of Express, you must have "/sqlexpress". And if the string is defined as a variable, VS2005 will also add a red wavy line under "/" to prompt you that "/s is an unrecognized escape sequence", so if the string is defined as a variable, it should be written as a server=.//sqlexpress
5. Register SQL Server database
The ASP.net SQL Server Setup Wizard Wizard appears when you run the aspnet_regsql command under the path "c:/windows/microsoft.net/framework/v2.0.50727". Press two consecutive next step will appear SQL Server registration interface, fill in the database parameters you want to register. After the registration will be in your database a few more tables (figure):

5. Set database connection string
Open iis-> The default Web site or the virtual directory where the site is located click the right mouse button to select Properties-> select ASP.net tab-> edit configuration-> Edit "LocalSqlServer" on the General page Database connection string:
data server=./sqlexpress;initial catalog=northwind; User Id=sa; password=sa123456
6. Set Web.config file
Add the following program to the Web.config file:
<connectionstrings>
<add name= " LocalSqlServer "connectionstring=" Data source=./sqlexpress;initial catalog=northwind; User Id=sa; password=sa123456 "Providername=" System.Data.SqlClient "/>
</connectionstrings>
that's it. The following tests
1. Relaxed connection test
Loose connection test use SqlDataSource
VS2005 Server Explorer to select the database right-click-> Select Modify Connection-> fill in Server name-> use SQL Server authentication fill in User name SA and password sa123456-> Select or enter a database name:northwind-> Click Test Connection
Loose connection test Connection success does not indicate that the database is connected OK, I was hanging here at first, The Loose connection test test connection was successful, but the contents of the database could not be read out to the Web page.
2. Rigorous connectivity test
Select the Site menu->asp in VS2005. NET configuration into the ASP.net web Site Administration Tool-> Select provider-> Click AspNetSqlProvider Test, if the test is successful, the database set up completely correct, otherwise have to look at the beginning of the problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.