none
SB ODBC drivers RRS feed

  • Question

  • Is there a way to get a list of ODBC drivers installed on Windows through Small Basic? 

    Thank you in advance.

    • Edited by a65001 Sunday, November 6, 2016 4:29 PM
    Sunday, November 6, 2016 4:29 PM

Answers

  • From SB??

    If you dont have a Registry extension, the only way i can imagine is via LDProcess.Start.

    According to ODBC Driver List from .NET

    i ran

    reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"   (or with a trailing  /s)

     and i see them listed there.

    To export a .reg file  "C:\Temp\HKLM-ODBCDrvrs.reg" , you could use:

    1.)

    regedit.exe /a C:\Temp\HKLM-ODBCDrvrs.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"           (export as REGEDIT4  format)

    2.)

    regedit.exe /e C:\Temp\HKLM-ODBCDrvrs.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"           (export as 'Windows Registry Editor Version 5.00-Format')

    or

    3.)  but 1.) or 2.) seems better (stays invisible, no popping cmd) and cmdline is more simple.

    reg.exe export "HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" C:\Temp\HKLM-ODBCDrvrs.txt

    using

    LDProcess.Start(application, arguments), like LDProcess.Start("regedit.exe", "appropriate CmdLine")

    and then extract the key values from eg. C:\Temp\HKLM-ODBCDrvrs.txt


    • Edited by Pappa LapubEditor Sunday, November 6, 2016 9:01 PM
    • Proposed as answer by litdevModerator Friday, November 18, 2016 6:47 PM
    • Marked as answer by a65001 Friday, November 18, 2016 8:30 PM
    Sunday, November 6, 2016 8:58 PM
    Answerer

All replies

  • Hi ! a65001

    i think you can do with PowerShell:  with the Get-OdbcDsn command

    i found this article :

    Get-OdbcDsn

    in Small Basic, no idea ?

    Sunday, November 6, 2016 4:57 PM
    Answerer
  • From SB??

    If you dont have a Registry extension, the only way i can imagine is via LDProcess.Start.

    According to ODBC Driver List from .NET

    i ran

    reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"   (or with a trailing  /s)

     and i see them listed there.

    To export a .reg file  "C:\Temp\HKLM-ODBCDrvrs.reg" , you could use:

    1.)

    regedit.exe /a C:\Temp\HKLM-ODBCDrvrs.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"           (export as REGEDIT4  format)

    2.)

    regedit.exe /e C:\Temp\HKLM-ODBCDrvrs.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"           (export as 'Windows Registry Editor Version 5.00-Format')

    or

    3.)  but 1.) or 2.) seems better (stays invisible, no popping cmd) and cmdline is more simple.

    reg.exe export "HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" C:\Temp\HKLM-ODBCDrvrs.txt

    using

    LDProcess.Start(application, arguments), like LDProcess.Start("regedit.exe", "appropriate CmdLine")

    and then extract the key values from eg. C:\Temp\HKLM-ODBCDrvrs.txt


    • Edited by Pappa LapubEditor Sunday, November 6, 2016 9:01 PM
    • Proposed as answer by litdevModerator Friday, November 18, 2016 6:47 PM
    • Marked as answer by a65001 Friday, November 18, 2016 8:30 PM
    Sunday, November 6, 2016 8:58 PM
    Answerer
  • I looked into powershell but apparently from what I understand Powershell needs to be allowed by the user.

    Thank you Papalub would all of them export into the "C:\Temp\HKLM-ODBCDrvrs.txt" file ?

    Sunday, November 6, 2016 9:02 PM
  • The whole tree structure down under

    "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"

    will be exported, but for me, there are NO subkeys, so my export looks:

    --------------------------------------------------------

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
    "SQL Server"="Installed"
    "SQL Server Native Client 11.0"="Installed"

    ----------------------------------------------------------

    The bold marked values, would be what you need, as i see it.

    PS: AND, as alternative you could use LDInline.Call ,

    to call a virtual compiled extension method which reads the values from registry. The code for this method you can implement as a 'Sub' directly in your code:  s. LDInline.IncludeCS, LDInline.IncludeJScript and LDinline.IncludeVB.


    Sunday, November 6, 2016 9:33 PM
    Answerer
  • Thank you :). Thats what one would plug into LDDatabase.ConnectOdbc in the driver section correct ?
    Sunday, November 6, 2016 9:51 PM
  • I'm NOT sure, if this are the right driver names for 'ConnectOdbc' method. LitDev ??

    I would just try it with the values, you find on your machine or follow LDDatabase.ConnectOdbc - ff. ... in Ilspy.

    Or see what LitDev says!

    Sunday, November 6, 2016 10:16 PM
    Answerer