EXPORT prototype LIST GetSQLServers();
function LIST GetSQLServers()
OBJECT objSqlServers,objItem,objAQLDMOApp;
string szSQLDMOSQLServer,szSQLDMOApp,szItem,szSQLServiceName1,szSQLServiceName;
LIST listID;
NUMBER nItemCnt,nStep,nType,nSize,nResult;
begin
/*nStep =0;
szSQLDMOApp ="SQLDMO.Application";
set objAQLDMOApp = CreateObject(szSQLDMOApp);
try
set objItem = objAQLDMOApp.ListAvailableSQLServers();
nItemCnt = objItem.Count;
nStep =1;
while(nStep < 5)
szItem = objItem.Item(nStep);
if(szItem[0] = "(" ) then
ListAddString (listID, szItem, AFTER);
endif;
nStep++;
endwhile;
catch
listID = NOTHING;
objItem = NOTHING;
endcatch;
if(szSQLServiceName1="") then
szSQLServiceName="MSSQL";
ListAddString (listID, szSQLServiceName, AFTER);
elseif(szSQLServiceName1!="MSSQLSERVER") then
szSQLServiceName="MSSQL$"+szSQLServiceName1;
ListAddString (listID, szSQLServiceName, AFTER);
else
szSQLServiceName=szSQLServiceName1;
ListAddString (listID, szSQLServiceName, AFTER);
endif;
*/
listID = ListCreate (STRINGLIST);
//获取服务器名称
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
nResult=RegDBGetKeyValueEx( "SOFTWARE\\Microsoft\\Microsoft SQL Server", "InstalledInstances", nType, szSQLServiceName1, nSize );
if(nResult < 0) then
szSQLServiceName="MSSQL" ;
else
ListAddString (listID, "(local)", AFTER);
endif;
nResult=RegDBGetKeyValueEx( "SOFTWARE\\Microsoft\\Microsoft SQL Server\\SQLEXPRESS\\Setup", "SQLPath", nType, szSQLServiceName1, nSize );
if(nResult < 0) then
szSQLServiceName="MSSQL" ;
else
ListAddString (listID, "(local)\\Express", AFTER);
endif;
return listID;
end;