Solved

get all dsn from odbc

Posted on 2001-07-25
5
145 Views
Last Modified: 2010-04-06
names and properties (like database driver).

thanks
0
Comment
Question by:jpcs
5 Comments
 
LVL 21

Accepted Solution

by:
gemarti earned 50 total points
ID: 6319353
The way I've been going today I'm almost afraid to post but here:

procedure TForm1.Button1Click(Sender: TObject);
var
  Reg: TRegistry;
  Val : TStringList;
  I : Integer;
begin
  Reg := TRegistry.Create;
  Val := TStringList.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\ODBC\ODBC.INI', False)
    then
      begin
        Reg.GetKeyNames(Val);
        For I := 0 to Val.Count - 1 do
          begin
            ListBox1.Items.Add(Val.Strings[i]);
          end;
      end;
  finally
    Reg.CloseKey;
    Reg.Free;
    Val.Free;
    inherited;
  end;

end;
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6319734
Change these two lines to get the System dsn's on the system

   Reg.RootKey := HKEY_LOCAL_MACHINE;
   if Reg.OpenKey('\Software\ODBC\ODBC.INI', False)


BTW you also need to add Registry to the uses clause.
0
 
LVL 1

Expert Comment

by:rootnash
ID: 6321017
add these for the properties....


procedure TForm1.ListBox1Click(Sender: TObject);
var
 Reg: TRegistry;
 Val: TStringList;
 I  : Integer;
 st : string;
begin
 Reg  := TRegistry.Create;
 Val  := TStringList.Create;
 try
   Listbox2.Clear;
   ListBox3.Clear;
   st := ListBox1.Items.Strings[ListBox1.ItemIndex];
   Reg.RootKey := HKEY_CURRENT_USER;
   if Reg.OpenKey('\Software\ODBC\ODBC.INI\'+ st, False) then
     begin
       Reg.GetValueNames(Val);
       For I := 0 to Val.Count - 1 do
         begin
           ListBox2.Items.Add(Val.Strings[i]);
           ListBox3.Items.Add('"'+Reg.ReadString(Val.Strings[I])+'"');
         end;
     end;
 finally
   Reg.CloseKey;
   Reg.Free;
   Val.Free;
   inherited;
 end;
end;


include another 2 listboxes, ListBox2(Name) and ListBox3(Data)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6842796
Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, in the event new items have been created since this listing was pulled.

http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11700518.html
http://www.experts-exchange.com/questions/Q.11747200.html
http://www.experts-exchange.com/questions/Q.20092793.html
http://www.experts-exchange.com/questions/Q.20132046.html
http://www.experts-exchange.com/questions/Q.20156965.html
http://www.experts-exchange.com/questions/Q.20174271.html
http://www.experts-exchange.com/questions/Q.20246680.html
http://www.experts-exchange.com/questions/Q.20258192.html


PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6903298
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question