Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages
Started by Thomas Goodson
Fri, 16 Jun 2006 21:07
How to find sql servers on lan
Author: Thomas Goodson
Date: Fri, 16 Jun 2006 21:07
Date: Fri, 16 Jun 2006 21:07
14 lines
1530 bytes
1530 bytes
I didn't get a response in sqlservers, so I thought I'd try here. Ok, I've got an application that works fine, but as part of deployment, I need to find all of the available MS-SQL / MSDE servers on the network and present a list to the installer. (the list part I can handle) I'm using ADO in the form of dbGo in BDS 2006 C++ mode. I really don't want to use PromptDataSource since it offers the user WAY to many ways to shoot themselves in the foot. (also, the database won't have been created yet). So, how do I find the available SQL servers? ** Tom **
Re: How to find sql servers on lan
Author: Ruben Lopez
Date: Mon, 19 Jun 2006 07:28
Date: Mon, 19 Jun 2006 07:28
67 lines
2783 bytes
2783 bytes
void GetServers(TStrings*Lista)
{
LPSQLDMOAPPLICATION pDMOApp = NULL;
LPSQLDMONAMELIST pNameList = NULL;
Lista->Clear();
try{
if SUCCEEDED(CoInitialize (NULL)){
// Crear SQLDMOApplication.
if SUCCEEDED(CoCreateInstance(CLSID_SQLDMOApplication,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWSQLDMOApplication,
(LPVOID*)&pDMOApp))
{
// Consultar lista de servidores
if SUCCEEDED(pDMOApp->ListAvailableSQLServers(&pNameList)){
long lCount=0;
BSTR strName=NULL;
//Numero de servidores
pNameList->GetCount(&lCount);
for(long i=0; i < lCount; i++){
//Nombre del servidor
pNameList->GetItemByOrd(i, &strName);
Lista->Add(strName);
}
}
if (pDMOApp){
pNameList = NULL;
pDMOApp->Release();
pDMOApp = NULL;
}
}
}
}
catch(...){
}
}
You need this header files
#include <initguid.h>
#include <sqldmoid.h>
#include <sqldmo.h>
This I'm not sure.
#include <utilcls.h>
Thomas Goodson escribi๏ฟฝ:
> I didn't get a response in sqlservers, so I thought I'd try here.
>
> Ok, I've got an application that works fine, but as part of deployment, I
> need to find all of the available MS-SQL / MSDE servers on the network and
> present a list to the installer. (the list part I can handle) I'm using
> ADO in the form of dbGo in BDS 2006 C++ mode.
>
> I really don't want to use PromptDataSource since it offers the user WAY to
> many ways to shoot themselves in the foot. (also, the database won't have
> been created yet).
>
> So, how do I find the available SQL servers?
>
> ** Tom **
>
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads