Solved

get all dsn from odbc

Posted on 2001-07-25
5
143 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now