1. Obtain the SQL SERVER service startup status through the registry. It is the same as obtaining the startup status of other services. The method is to find the Start key value in the Registry: HK_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ {service name. The value indicates:
- 2 indicates Automatic)
- 3 indicates Manual)
- 4 indicates disabled (Diabled)
2. Get or set the startup status of SqlServer.
You can use the System. ServiceProcess. ServiceController class to obtain or set the service status.
3. Obtain or set the protocol enabled by Sqlserver.
Sqlserver provides four Protocols: sharemememory, Named Pipe, Tcp, and.
You can also query the registry to determine whether a protocol is enabled. The following example shows whether the Tcp protocol under SqlExpress is enabled.
- Generally, each SQL server Instance has a key under HK_LOCAL_MACHINE \ Software \ Microsoft SQL Server \ Instance \ SQL. Obtain the value of the SQLEXPRESS key in this directory. Assume MSSQL.1.
- Go to HK_LOCAL_MACHINE \ Software \ Microsoft SQL Server \ MSSQL.1 \ MSSQLServer \ SuperSocketNetLib and you can see that each of the four directories represents a protocol. Among them, Np represents Named Pipe, Sm represents Shared Memory, and the other two are Tcp and.
- View the value of the Enabled key under Tcp. If the value is 1, the Protocol is enabled, and 0 indicates that the Protocol is disabled.