设置数据链接文件而不是连接字符串

发布于 2024-10-02 07:47:01 字数 125 浏览 0 评论 0原文

delphi 7中,

打开数据库连接时,可以选择数据链接文件,或连接字符串。

当程序编译时,它使用连接字符串进行连接。在运行时,需要更改为用户输入 udl。

为了改变连接需要改变什么属性?

delphi 7,

when opening a connection to db, you can choose data link file, or Connection String.

when the program compiles , it connects with connection string. on run time, there is a need to change to an user input udl.

what is the property to change in order to change the conneciton?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天煞孤星 2024-10-09 07:47:01

下面的代码假设您有一个用于选择文件的 TOpenDialog (OpenDialog1) 实例和一个 TAdoConnection (AdoConnection1) 实例。它根据所选的 .udl 文件设置连接字符串。

  if OpenDialog1.Execute then
  begin
    AdoConnection1.Connected := False;
    AdoConnection1.ConnectionString := 'FILE NAME=' + OpenDialog1.FileName;
    AdoConnection1.Connected := True;
  end;

The code below assumes you have an instance of TOpenDialog (OpenDialog1) for selecting a file, and an instance of TAdoConnection (AdoConnection1). It sets connection string according to the selected .udl file.

  if OpenDialog1.Execute then
  begin
    AdoConnection1.Connected := False;
    AdoConnection1.ConnectionString := 'FILE NAME=' + OpenDialog1.FileName;
    AdoConnection1.Connected := True;
  end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文