Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically determine Server and database
Message
From
07/09/2006 10:05:47
 
 
To
07/09/2006 09:35:18
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01151434
Message ID:
01151780
Views:
44
What's interesting is that if I try this code:
LOCAL loApplication AS SQLDMO.APPLICATION
LOCAL loNameList AS SQLDMO.NameList

CREATE CURSOR c_ServerREsultsDMO;
(cServerName C(254))

m.loApplication = CREATEOBJECT("SQLDMO.Application")
WITH m.loApplication
	m.loNameList = .ListAvailableSQLServers
	WITH m.loNameList
		FOR intIndex = 1 TO .COUNT
			m.cServerName = m.loNameList.ITEM(intIndex)
			INSERT INTO c_ServerResultsDMO FROM MEMVAR
		ENDFOR
	ENDWITH
ENDWITH
RELEASE m.loApplication
I end up with 5 records:
(local)
SAMAAN3
SAMAAN5
SAMAAN5\SQLEXPRESS
SERVER1

But running the EnumerateServers function I only get 3 servers:
SAMAAN3
SAMAAN5
SERVER1

I wonder why the difference and also why SAMAAN5\SQLEXPRESS showed up in the list, but not SAMAAN3\SQLEXPRESS.

>Hi Sergey,
>
>to follow up on this I used the API and have been able to get out all my servers. However, on one server I use a connection string specifying the server as this:
>
>SERVER=SAMAAN3\SQLEXPRESS
>
>But the returned list of servers just has SAMAAN3 in it.
>
>What do I do to get the SQLEXPRESS part?
>
>Thanks.
>
>>You're welcome.
>>
>>>Thanks very much Sergey!
>>>
>>>>See Re: How get list of available SQL servers? Message #1096090 and Re: List of Servers Message #936587
>>>>
>>>>>I'll see if I can get one of those to work. I like the idea of using the Windows API, but I'm not sure how I would call it after defining it like this:
>>>>>
>>>>>DECLARE INTEGER NetServerEnum IN netapi32;
>>>>>	INTEGER servername, INTEGER level,;
>>>>>	INTEGER @bufptr, INTEGER prefmaxlen,;
>>>>>	INTEGER @entriesread, INTEGER @totalentries,;
>>>>>	INTEGER servertype, INTEGER domain,;
>>>>>	INTEGER resume_handle
>>>>>
>>>>>
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform