Results 1 to 4 of 4

Thread: ODBC Environment Handle

  1. #1
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185

    ODBC Environment Handle

    I have a nice routine (in Windows) to check whether particular ODBC drivers are installed, modified from a post on an MSDN forum (of all places: the one time I actually found something useful there). The purpose is to find out which of the acceptable drivers is there, and if so, use the most preferred one. If not, throw an intelligent error before a call is attempted.

    However, the Windows prg uses sys(3053), which is described in the VFP help as:

    If ODBC isn't loaded, SYS(3053) loads it and returns the ODBC environment handle.
    The environment handle returned by SYS(3053) provides access to ODBC through ODBC API calls. Access to the ODBC API is available in Visual FoxPro through DECLARE - DLL, and through external Visual FoxPro API library routines.
    Only one ODBC environment handle should be used at any time. A Visual FoxPro program using ODBC calls should use SYS(3053) to get the ODBC environment handle rather than reallocating and freeing the ODBC environment handle through ODBC API calls.
    Exercise care when manipulating an ODBC environment handle. For further information about the ODBC API, see the Microsoft ODBC SDK documentation.

    Is there something equivalent in Lianja?

    thanks,

    Hank

    PS: For Linux (which I will do later), it seems that registration is in etc/odbc/ but I will have to explore more what's available in LInux, in particular, whether getting a list of installed ODBC drivers can also be approached programmatically.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    The best solution would be to provide an operating system independent function to return an array of data sources rather than a windows specific hack using DECLARE DLL that will break on Linux and macOS.

    SQLODBCDrivers()
    SQLODBCDataSources()

    Please Submit an ER.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Incidentally this information is all in the windows registry on windows but providing registry functions for this would be windows specific which is not an acceptable solution IMO.
    Last edited by barrymavin; 2017-12-28 at 11:46.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Wow, that's fantastic.

    ER submitted.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us