naren
naren

Reputation: 629

odbc datasource connection at runtime through delphi

can we create ODBC datasource connection at runtime? If yes then can you plz help regarding how to do it. Currently I am created the ODBC datasource connection manually through Control Panel--> Administrative Tools --> Datasources. But i want to create that at runtime when user run application.

thanks for the help.

Upvotes: 0

Views: 1868

Answers (2)

PA.
PA.

Reputation: 29369

Yes, you can do it. As @TOndrej points out, you can create a ODBC datasource at runtime. But usually you don't need to. You might just create a Data Connection in runtime without an ODBC datasource.

Something like this, using ADO components to a MS Jet OLE DB ...

  if ADOConnection1.connected then ADOConnection1.close;
  ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;'+
                'Data Source='+filename+';'+
                'Persist Security Info=False';
  ADOConnection1.LoginPrompt:=false;
  ADOQuery1.Connection:=ADOConnection1;
  ADOConnection1.Open;
  ....

Upvotes: 0

Ondrej Kelle
Ondrej Kelle

Reputation: 37221

You can use SQLConfigDataSource (Delphi example).

Upvotes: 2

Related Questions