* * *

Author Topic: List ODBC data sources in combobox  (Read 252 times)

mm_coder

  • New member
  • *
  • Posts: 12
List ODBC data sources in combobox
« on: March 13, 2017, 08:37:50 pm »
Porting a vb6 application to Lazarus.

I need to know how to display the list of installed ODBC drivers in a combo box for
the user to select for application setup.

Windows platform

Thaddy

  • Hero Member
  • *****
  • Posts: 3031
Re: List ODBC data sources in combobox
« Reply #1 on: March 13, 2017, 09:25:06 pm »
Something like:
Code: Pascal  [Select]
  1. // add registry to the uses clause
  2. procedure TForm1.FormCreate(Sender: TObject);
  3. var
  4.   Reg:TRegistry;
  5. begin
  6.  Reg := TRegistry.Create;
  7.  try
  8.    Reg.RootKey:= HKEY_LOCAL_MACHINE;
  9.    Reg.OpenKey('Software\ODBC\ODBCINST.INI\ODBC Drivers',False);
  10.    Reg.GetValueNames(Combobox1.Items);
  11.  finally
  12.    Reg.Free;
  13.  end;
  14. end;
  15.  
« Last Edit: March 13, 2017, 09:49:56 pm by Thaddy »

eny

  • Hero Member
  • *****
  • Posts: 1540
Re: List ODBC data sources in combobox
« Reply #2 on: March 13, 2017, 10:19:43 pm »
Windows platform
Also note that in case you are using SQL Server (small chance  ofc :D) Windows has a new ODBC driver that requires a separate download and installation.
All posts based on: Win10 (Win64); Lazarus 1.4.2 'stable' (#49524 win32) unless specified otherwise...

mm_coder

  • New member
  • *
  • Posts: 12
Re: List ODBC data sources in combobox
« Reply #3 on: March 14, 2017, 12:14:08 am »
Working perfectly. Thanks for taking the time.

Still getting used to the pascal way.
Thanks

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus