Reghu
February 1st, 2000, 07:30 AM
How to fill a combobox with available DSN entries?
Initiative is to success what a lighted match is to a candle...
Initiative is to success what a lighted match is to a candle...
|
Click to See Complete Forum and Search --> : How to fill a combobox with available DSN entries? Reghu February 1st, 2000, 07:30 AM How to fill a combobox with available DSN entries? Initiative is to success what a lighted match is to a candle... Johnny101 February 1st, 2000, 11:54 AM This is some code that I use to get a list of DSNs and also a list of drivers... private Declare Function SQLDataSources Lib "ODBC32.DLL" (byval henv&, byval fDirection%, byval szDSN$, byval cbDSNMax%, pcbDSN%, byval szDescription$, byval cbDescriptionMax%, pcbDescription%) as Integer private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&) Const SQL_SUCCESS as Long = 0 Const SQL_FETCH_NEXT as Long = 1 Sub GetDSNsAndDrivers() Dim i as Integer Dim sDSNItem as string * 1024 Dim sDRVItem as string * 1024 Dim sDSN as string Dim sDRV as string Dim iDSNLen as Integer Dim iDRVLen as Integer Dim lHenv as Long 'handle to the environment on error resume next cboDSNList.AddItem "(None)" 'get the DSNs If SQLAllocEnv(lHenv) <> -1 then Do Until i <> SQL_SUCCESS sDSNItem = Space$(1024) sDRVItem = Space$(1024) i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen) sDSN = Left$(sDSNItem, iDSNLen) sDRV = Left$(sDRVItem, iDRVLen) If sDSN <> Space(iDSNLen) then cboDSNList.AddItem sDSN cboDrivers.AddItem sDRV '---optional - driver value returned End If Loop End If 'remove the dups If cboDSNList.ListCount > 0 then With cboDrivers If .ListCount > 1 then i = 0 While i < .ListCount If .List(i) = .List(i + 1) then .RemoveItem (i) else i = i + 1 End If Wend End If End With End If cboDSNList.ListIndex = 0 End Sub If you don't want the drivers list, then just don't do anything with the data that comes back. Hope this helps, John John Pirkey MCSD www.ShallowWaterSystems.com Chris Eastwood February 1st, 2000, 03:47 PM That's excellent - would you like me to post it onto the site for you ? Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb Johnny101 February 1st, 2000, 04:59 PM If you feel that its worthy, then be my guest. Thanks for the compliment. John John Pirkey MCSD www.ShallowWaterSystems.com Reghu February 2nd, 2000, 04:28 AM Yes, definitely. I am obliged Thanks in advance Initiative is to success what a lighted match is to a candle... Reghu February 2nd, 2000, 04:33 AM Thanks for helping me out... How to become ur guest? i have tried visiting the web site and haven't seen any guest book.... Bye Bye Initiative is to success what a lighted match is to a candle... Johnny101 February 2nd, 2000, 10:34 AM I don't currently have a guest book at that location. To be honest, I haven't updated that site recently. Most of my time has been spent working on www.stlvbug.org. Just the visit to my site was thanks enough. Let me know if I can help you out with anything else. John John Pirkey MCSD www.ShallowWaterSystems.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |