Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a list of DSN's......
Message
From
17/01/2003 10:18:24
 
 
To
16/01/2003 21:04:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00742712
Message ID:
00742874
Views:
20
This message has been marked as the solution to the initial question of the thread.
This combbox uses the registry class from the foundation class libararies. It also stores the selected value in the registry using VFE application object methods. You could take this code out.
**************************************************
*-- Class:        dsnpreference (c:\vfe_apps\totalhr41\libs\acontrls.vcx)
*-- ParentClass:  icombobox (c:\vfe_apps\totalhr41\ilibs\icontrls.vcx)
*-- BaseClass:    combobox
*-- Time Stamp:   03/26/01 06:25:08 PM
*
#INCLUDE "c:\vfe7\vfeframe\include\vfe.h"
*
DEFINE CLASS dsnpreference AS icombobox


	ColumnCount = (ALEN(This.aODBCData,2))
	ColumnWidths = "140,0"
	RowSourceType = 5
	RowSource = "This.aODBCData"
	FirstElement = 1
	NumberOfElements = (ALEN(This.aODBCData))
	Name = "dsnpreference"
	DIMENSION aodbcdata[1]


	PROCEDURE Init
		Local oReg, aODBCData, cPreferenceValue

		With This

			oReg = createobj('odbcreg')

			Dimension aODBCData[1]

			oReg.GetODBCDrvrs(@aODBCData,.t.)

			Acopy(aODBCData, .aODBCData)

			.NumberOFElements = alen(.aODBCData)
			.Requery()

			cPreferenceValue = This.oApplication.GetSetting('preferences','Data Source Name')

			If NOT EMPTY(cPreferenceValue)
				.Value = cPreferenceValue
			Endif

		Endwith
	ENDPROC


	PROCEDURE InteractiveChange
		This.oApplication.SetSetting('preferences','Data Source Name',This.Value)
	ENDPROC


ENDDEFINE
*
*-- EndDefine: dsnpreference
**************************************************
>Hi everyone,
>
>Well, time to try something new - for me. Anyway, I want to search the registry and find out all of the DSN's which are available and then drop them into an array (arrMyDsn). To be honest, I don't use the registry class that much so there is a lot I don't know. I do use it (the registry) to return things like if there is an application installed, but that is about it. I have looked up all of the threads on this subject, and read them; and even went to the downloads as some of them suggested, but there does not seem to be a 'help file' per say which details what to ask the registry to return. So, let me put down a guess on what I want to do and don't be shy about responding and telling me 'no silly, it should be this way...'... TIA
>
>Ric
>
>PS. Thanks to the many threads I went through to get this far... especially Mark McCasland
>
>
*-- Assume registry object exists (default foundation class of VFP 7.0)
>*-- So, oRegistry is an object
>LOCAL lcRHKey, lcRSubKey, lcDSNName, laVals[1,2]
>*-- now, I found some DSN's here in the registry
>lcRHKey   = HKEY_CURRENT_USER
>lcRSubKey = "Software\ODBC\ODBC.INI\"
>*-- Here is what I don't know....
>
>lcDSNName = oRegistry.GetEnumValues(@laVals, lcRegHKey, lcRegSubKey)
>*-- This does not work at all... I'm thinking I need to put in a for each loItem type thingy, but not sure...
>
>RETURN lcDSNName
>
>Thank you very much...
>
>Ric
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform