ListInstalledInstances doesn't return a string?

From: BartMan (anonymous_at_discussions.microsoft.com)
Date: 05/17/04


Date: Mon, 17 May 2004 08:06:03 -0700

Greetings,

I have 2 instances of msde sql server 2000 sp3 installed on my computer with windows xp professional.
I am doing development using visual C++ 2003, and I can get a list of the sql servers found on our network.
But when I try to do a "ListInstalledInstances" I always get back a "null" string. Do I have to do something with security to allow for this?

Here is a code snippet of what I am doing:

HRESULT CDlgSqlServerList::AddSQLSvrInstances(CComBSTR strSvrName)
{
        _SQLServer2Ptr spSQLServer;
               HRESULT hr = spSQLServer.CreateInstance(__uuidof(SQLServer2));
        if(FAILED(hr)) return hr;

        NameListPtr listInstances;
        _variant_t varServ(strSvrName);
        hr = spSQLServer->raw_ListInstalledInstances(varServ,&listInstances);
        if(FAILED(hr)) return hr;
        if(listInstances == NULL) return S_OK;
        
        LONG lInstanceCount = 0;
        hr = listInstances->get_Count(&lInstanceCount);
        if(FAILED(hr)) return hr;

        for(LONG lIndex=0;lIndex<lInstanceCount;lIndex++)
        {
                         CComBSTR strInstance;
                hr = listInstances->raw_Item(CComVariant(lIndex), &strInstance);
                                if(FAILED(hr)) continue;

                CStringW sInstance;
                sInstance.Format(L"%s",(LPWSTR)strInstance);
                ATLTRACE(L"%s\n",sInstance);
        }
}

For some reason I get a count of "1" from the "listInstances->get_Count()", but there is never a value in the string.
I use the name "(local) for the server name. (which I had enumerated using "ListAvailableSQLServers")

Any ideas as to what I am doing wrong?
Thanks in advance for any help.



Relevant Pages

  • List SQL servers in a network
    ... Most of the solutions use SQLDMO to list all sql servers in the network like ... public static string[] GetAvailableSQLServers ... - this does not work with Windows XP (see SQLDMO documentation: ...
    (microsoft.public.dotnet.general)
  • Remote connection errors
    ... When trying to connect to 2 of my SQL Servers I am getting General Network ... SQLState: 08S01 Native Error: 11 ...
    (microsoft.public.sqlserver.connect)
  • System Area Network Beginners Questions
    ... Network and linking several SQL servers using the VIA protocol. ...
    (microsoft.public.sqlserver.connect)
  • Re: sql servers part of workgroup
    ... I don't think automatic log shipping is possible without a domain. ... As for backups to network drives then make sure the network share has ... > I have a client that has a couple of SQL Servers that are> part of a workgroup. ... > Now they want to do some activity such as log shipping,> network backups, etc.. ...
    (microsoft.public.sqlserver.server)
  • Need help On NTBACKUP
    ... Happy X-mas ans holidays ... i have 3 sql servers in my network. ...
    (microsoft.public.windows.server.general)