SqlUtilEnumerateServers - cDbUpdateFunctionLibrary
Enumerates SQL servers for the passed driver ID.
Type: Function
Parameters: String sDriverID Integer iDataSoureType
Parameter |
Description |
sDriverID |
MSSQLDRV_ID, DB2_DRV_ID,ODBC_DRV_ID, ORAFLEX, SQLFLEX, MDSPgSQL or MDSMySQL |
iDataSourceType |
Optional parameter. For the ODBC driver only. One of three values; SQL_FETCH_USER, SQL_FETCH_SYSTEM or SQL_FETCH_ALL that refers to what ODBC source should be enumerated. Use SQL_FETCH_ALL if unsure as it will return all data sources. |
Syntax
Function SQLUtilEnumerateServers String sDriverID Integer iDataSourceType Returns String[]
Call: |
Get SQLUtilEnumerateServers MSSQLDRV_ID to sMyServerArray |
Description
Use it to retrieve all SQL servers or DSN sources on a machine. The return value is a string array.
Note: It can be used in e.g. a selection list or grid object to display Servers/DSN sources.
Example
Procedure Activating
tDataSourceRow[] MyData
Handle hoDataSource
String[] sValueArray
String sDriverID
Integer iCount iSize
Send Cursor_Wait of Cursor_Control
Forward Send Activating
Get psDriverID to sDriverID
Send Ignore_Error of Error_Object_Id DFERR_CANT_LOAD_DLL
Load_Driver sDriverID
Send Trap_Error of Error_Object_Id DFERR_CANT_LOAD_DLL
If (LastErr = 4255) Begin
Send Info_Box ("Can't display any items because the database driver could not be loaded. (" + sDriverID + ")")
Procedure_Return
End
Get SqlUtilEnumerateServers of ghoDbUpdateFunctionLibrary sDriverID SQL_FETCH_ALL to sValueArray
Move (SizeOfArray(sValueArray)) to iSize
Decrement iSize
For iCount from 0 to iSize
Move sValueArray[iCount] to MyData[iCount].sValue[0]
Loop
Get phoDataSource to hoDataSource
Send InitializeData of hoDataSource MyData
Send Cursor_Ready of Cursor_Control
End_Procedure