Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List Of SQL Servers
Message
From
19/12/2006 06:07:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
18/12/2006 20:31:43
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01178456
Message ID:
01178806
Views:
22
Frank,
I stand corrected about one point. On this machine I only have SQL2000 dev. and SQL2005 Express. On computer where it listed all I had additional SQL2005 dev. edition (but I doubt now if it would list there either).
Using configuration manager you can hide an instance at your will. What's strange is I didn't set option to hide. All settings are at their default.
Dataexplorer (or other tools like udl) only list the default SQL2000 instance.
Cetin

>Hi Cetin,
>
>I remember posting the code before, but couldn't remember if it was for you or not. Strange that it doesn't return all of your instances. Is there anything common with the missing ones? I haven't used this extensively, but it has not missed any instances on the systems I have tried it on.
>
>BTW, the code is from the VFPSource, I just modified it slightly for my use. Does the data Explorer return all instances? If so, then my modifications may have broken something.
>
>>Frank,
>>Do you remember SQLDMO/SMO thread where I found this code of yours great? While the code is great unfortunately it doesn't return all instances (as I said in a previous message this code too just returns 1 of my 3 instances).
>>Cetin
>>
>>>Hi Kevin,
>>>
>>>Here's some code that I adjusted from the data explorer in VFP, you pass in a the name of a cursor that already exists (or you could adjust the code to suit how you want to store the list):
>>>
>>>CREATE CURSOR c_Servers;
>>>	(cServerName C(100))
>>>
>>>
>>>
>>>LPARAMETERS tcCursor
>>>
>>>* Populate collection with available SQL servers
>>>#DEFINE SQL_HANDLE_ENV			1
>>>#DEFINE SQL_HANDLE_DBC			2
>>>#DEFINE SQL_ATTR_ODBC_VERSION	200
>>>#DEFINE SQL_OV_ODBC3			3
>>>#DEFINE SQL_SUCCESS				0
>>>#DEFINE SQL_NEED_DATA			99
>>>#DEFINE DEFAULT_RESULT_SIZE		2048
>>>#DEFINE SQL_DRIVER_STR			"DRIVER=SQL SERVER";
>>>
>>>LOCAL hEnv
>>>LOCAL hConn
>>>LOCAL cInString
>>>LOCAL cOutString
>>>LOCAL nLenOutString
>>>LOCAL ARRAY aServerList[1]
>>>
>>>DECLARE SHORT SQLBrowseConnect IN odbc32 ;
>>>	INTEGER   ConnectionHandle, ;
>>>	STRING    InConnectionString, ;
>>>	INTEGER   StringLength1, ;
>>>	STRING  @ OutConnectionString, ;
>>>	INTEGER   BufferLength, ;
>>>	INTEGER @ StringLength2Ptr
>>>
>>>DECLARE SHORT SQLAllocHandle IN odbc32 ;
>>>	INTEGER   HandleType, ;
>>>	INTEGER   InputHandle, ;
>>>	INTEGER @ OutputHandlePtr
>>>
>>>DECLARE SHORT SQLFreeHandle IN odbc32 ;
>>>	INTEGER HandleType, ;
>>>	INTEGER Handle
>>>
>>>DECLARE SHORT SQLSetEnvAttr IN odbc32 ;
>>>	INTEGER EnvironmentHandle, ;
>>>	INTEGER ATTRIBUTE, ;
>>>	INTEGER ValuePtr, ;
>>>	INTEGER StringLength
>>>
>>>
>>>hEnv = 0
>>>hConn = 0
>>>cInString = SQL_DRIVER_STR
>>>cOutString = SPACE(DEFAULT_RESULT_SIZE)
>>>nLenOutString = 0
>>>
>>>ZAP IN (m.tcCursor)
>>>
>>>TRY
>>>	IF SQLAllocHandle(SQL_HANDLE_ENV, hEnv, @hEnv) == SQL_SUCCESS
>>>		IF (SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0)) == SQL_SUCCESS
>>>			IF SQLAllocHandle(SQL_HANDLE_DBC, hEnv, @hConn) == SQL_SUCCESS
>>>				IF (SQLBrowseConnect(hConn, @cInString, LEN(cInString), @cOutString, DEFAULT_RESULT_SIZE, @nLenOutString)) == SQL_NEED_DATA
>>>					nCnt = ALINES(aServerList, STREXTRACT(cOutString, '{', '}'), .T., ',')
>>>					FOR i = 1 TO nCnt
>>>						*!*									oServerCollection.AddEntity(aServerList[i])
>>>						INSERT INTO (m.tcCursor) (cServerName) VALUES (RTRIM(aServerList[i]))
>>>					ENDFOR
>>>				ENDIF
>>>			ENDIF
>>>		ENDIF
>>>	ENDIF
>>>CATCH TO oException
>>>	* ignore error, just return an empty collection of servers
>>>	MESSAGEBOX(oException.Message, 0+16, _screen.caption)
>>>FINALLY
>>>	IF hConn <> 0
>>>		SQLFreeHandle(SQL_HANDLE_DBC, hConn)
>>>	ENDIF
>>>	IF hEnv <> 0
>>>		SQLFreeHandle(SQL_HANDLE_ENV, hConn)
>>>	ENDIF
>>>ENDTRY
>>>
>>>
>>>
>>>>How can I return a list of SQL servers in VFP?
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform