调出连接串编辑对话框
当发布一个使用 ADO 连接的应用程序时,开发者有时需要在应用程序里设置 ADO 的连接串。ADO 连接串既长又复杂。我常将他们存贮在注册表中。但是,假如我需要生成一个新的串,困难出现了。从前我只好运行 Delphi,通过它的 IDE,运行 ADO 连接串的属性编辑器来建立。现在我发现我可以在自己的应用程序中完成这种事情了。
首先,在 uses 语句中包含进 AdoConEd 单元。然后在应用程序需要触发 ADO 连接串编辑器的地方写入如下简单代码。问题迎刃而解。
ADOConnection1.Close;
// calling EditConnectionString displays the dialog, and
// sets the ConnectString property to the resulting value.
if EditConnectionString(ADOConnection1) then begin
//display the resulting ADO Connect String, just for fun.
label11.caption := ADOConnection1.ConnectionString;
end;