Solved

ADO Connection String

Posted on 2001-09-05
4
211 Views
Last Modified: 2013-11-23
Hi Guys,
   Any idea how I launch the connection string dialogue through code and recieve the connection string.

{
In the ADOConnection component clicking the ... button next to the connectionstring property causes a connection string dialogue with a BUILD button that lets you build your connection string
}

I need to be able to launch that dialogue though code.

Many Thanks
John.
0
Comment
Question by:WoodyJ007
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6456202
Hello

  I don't know if i understand you well, but if you want to set the connectionstrings from code, this code, will connect to access database the file on the c:\

procedure TForm1.Button1Click(Sender: TObject);
begin
  ADOTable1.ConnectionString. := 'Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=c:\db1.mdb;Persist Security Info=True';
  ADoTable1.TableName := 'Users';
  ADOTable1.Active := True;
end;
0
 

Author Comment

by:WoodyJ007
ID: 6456261
I want to show the dialog.  With the ConnectionString Dialogue you can choose many different types of connection.
0
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 6456266
hi,
to show the dialog at runtime you can do:

procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
begin
  if adoconnection1.connected then
  begin
    adoconnection1.Connected:=false;
  end else
  begin
    s := adoconnection1.ConnectionString;
    s := adodb.PromptDataSource(self.Handle, s);
    adoconnection1.ConnectionString := s;
    try
      adoconnection1.connected:=true;
    except
    end;
  end;
  memo1.text := s;
end;
0
 

Author Comment

by:WoodyJ007
ID: 6456275
thats great.

Thanks
Woody.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 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