solution when sql server displays error,"error: 40"

created at 08-05-2021 views: 2

Recently, when using the SQL Server database, an error message of error: 40 appeared unexpectedly.

After sorting out, there are two main situations where this error will appear: it pops up when opening SQL Server 2005; it appears when the application connects to SQL Server 2005.

So what caused the error: 40? In summary, there are several reasons:

1 The database engine is not started

Two startup methods:

(1) Start->Programs->Microsoft SQL Server 2005->SQL Server 2005 Peripheral Application Configurator, click "Service Connection Peripheral Application Configurator" in the opened interface, find Database Engine in the opened interface, click Click "Service" and check whether it has been started on the right side. If it is not started, click "Start" and make sure that the "Startup Type" is automatic, not manual, otherwise you will have to start it manually the next time it is turned on;

(2) It can be opened: Start -> Programs -> Microsoft SQL Server 2005 (51aspx) -> Configuration Tools -> SQL Server Configuration Manager, select SQL Server (MSSQLSERVER) in the SQL Server 2005 service, and click "in the toolbar Start the service" button to change the service status to start;

When using the above two methods, sometimes an error may occur during startup and cannot be started. In this case, check the SQL Server 2005 network configuration in the "SQL Server 2005 Configuration Manager" -> whether the VIA in the MSSQLSERVER protocol has been Enable, if it is enabled, disable it. Then perform one of the above operations.

2 When making a remote connection, whether the remote connection has been allowed

SQL Server 2005 is limited to local connections by default, and we can manually enable remote connections. In the first method above, find Database Engine, click "remote connection", change "local connection only (L)" to "local connection and remote connection (R)" on the right, and select "simultaneous use TCP/IP and named pipes(B)".

3 If it is a remote connection, check whether the statement connecting to the database is correct, whether the login account is correct, and whether the password is correct

When I connect to the database in the local area network, there is a problem with the connection string. When one machine connects to the database in another machine in the local area network. I always get the above error when connecting to the database. After checking it for a long time, I found out that the IP was not correctly transmitted to the connection string. It turns out that when I was connecting, I used the local device, which is, and the IP entered was not passed to the connection string.

created at:08-05-2021
edited at: 08-05-2021: