PingSQLServerVersion Method
未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。
The PingSQLServerVersion method returns a long integer that describes an instance of Microsoft SQL Server.
語法
object.PingSQLServerVersion( [ ServerName ] , [ Login ] , [ Password ] )as SQLDMO_SQL_VER
Parts
object
Expression that evaluates to an object in the Applies To list.ServerName
Optional. A string that identifies an instance of SQL Server by installed name.Login
Optional. A string that identifies an existing SQL Server login by name.Password
Optional. A string that supplies a password and is used for authentication of the Login argument in method execution.
Prototype (C/C++)
HRESULT PingSQLServerVersion(SQLDMO_SQL_VER *pRetVal,
SQLDMO_LPCSTR szServerName, SQLDMO_LPCSTR szLogin,
SQLDMO_LPCSTR szPassword);
Returns
Evaluate the return value of the PingSQLServerVersion method by using these SQLDMO_SQL_VER values.
Constant |
Value |
Description |
---|---|---|
SQLDMOSQLVer_60 |
2 |
SQL Server version 6.0 |
SQLDMOSQLVer_65 |
4 |
SQL Server version 6.5 |
SQLDMOSQLVer_70 |
8 |
SQL Server version 7.0 |
SQLDMOSQLVer_80 |
16 |
SQL Server 2000 |
SQLDMOSQLVer_90 |
32 |
SQL Server 2005 |
SQLDMOSQLVer_Pre_60 |
1 |
SQL Server version 6.0 or earlier |
SQLDMOSQLVer_Unknown |
0 |
Bad or invalid value |
備註
The SQL Distributed Management Objects (SQL-DMO) object library released with later versions of SQL Server cannot connect to or be used to administer an instance of SQL Server with a version earlier than 7.0. To administer instances of SQL Server 7.0 and earlier, an application can reference the SQL-DMO object library released with SQL Server 2000 or later, and the library released with an earlier version.
The PingSQLServerVersion method:
Connects to an instance of SQL Server.
Queries the instance for version information.
Disconnects from the instance indicated.
The method cannot be used on a connected SQLServer object.
When the ServerName argument is not specified, the PingSQLServerVersion method attempts to connect to an instance of SQL Server using the network name of the computer on which the application is running.
When used, the Login and Password arguments indicate use of SQL Server Authentication for connection validation. When no value is supplied in the Login argument, Windows Authentication is used for connection validation and any value applied in the Password argument is ignored.