OleObject lole_test, lole_namelistinteger li_retlong ll_count, ll_index
LOLE_TEST = CREATE OLEOBJECTLOLE_NAMELIST = CREATE OLEOBJECT
LI_RET = LOLE_TEST.CONNECTTONEWOBJECT ('SqldMo.application') if Li_Ret <> 0 Then Destroy Lole_Test MessageBox ('System Information', 'SqlDMO Object Connection Failed ") Returnend IF
Lole_namelist = lole_test.listavailablesqlservers ()
LOLE_TEST.DISCONNECTOBJECT () DESTROY LOLE_TEST
Ll_count = like_namelist.countfor ll_index = 1 to ll_count messagebox ('SQLServer instance name "present in the current network", string (lole_namelist.item (ll_index))) NEXT
Destroy lole_namelist
With the above method, you can get the SQLServer instance name existing in the current network, and then determine which includes the native machine name (if there is no slant line /, that is the machine name in that instance, if there is a slash, then the slash The instance is in the machine name), it should be the instance name installed in this unit.