易截截图软件、单文件、免安装、纯绿色、仅160KB

在Delphi中如何创建和使用udl文件


方法一:
直接弹出UDL对话框:
use
ADOConed;
  EditConnectionString(ADOQuery1);
方法二:
⑴、右键---新建---文本文档,重命名为 connSet.udl 。
⑵、双击打开 connSet.udl 按提示操作配置数据库,选择本地或远程数据库,配置好后退出。
⑶、使用Delphi 控件TADOConnection连接代码:
  在Form1的OnCreate事件如下
 try
        ADOC.Connected := false;
        ADOC.ConnectionString := '';
        ADOC.ConnectionString := 'FILE NAME='+ExtractFilePath(ParamStr(0))+'\connSet.udl';
        ADOC.Provider := ExtractFilePath(ParamStr(0))+'\connSet.udl';
        ADOC.Connected := true;
    except
        showmessage('连接失败,请重新配置connSet.udl文件');
        EXIT;
    end;
⑷、如果你要把应用程序分发到局域网中使用,数据库服务器没有改变,直接复制应用程序就可以了,不用再配置connSet.udl 文件。当在另外一个局域网中安装有不同名的数据库服务器时,右键用记事本打开connSet.udl 文件,会看到:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=jfgl_sa;Initial Catalog=jfgl;Data Source=192.168.0.117
上面几行文件,这是新建connSet.udl 文件,并配置好数据库后自动生成的代码。我默认的登录用户为jfgl_sa,密码为空,数据库为jfgl,局域网数据库服务器名IP:192.168.0.117,你可按照自己的实际环境进行配置。
⑸、不同的局域网数据库服务器,你只要修改配置connSet.udl连接文件就可以了,不用修改Delphi代码,很方便哦。
⑹、
故障处理:如果运行应用程序时,出现错误提示“无效的授权说明”,是因为前面我们已经新建了connSet.udl
连接,现在只要把Delphi控件TADOConnection的属性ConnectionString值删除为空,这是静态连接数据库的字符串值,所以
删除ConnectionString值后,再重新编译就可以了。
用方法二自测成功,在本地基于oracle 10g开发的程序,放到另外装有oracl


相关文档:

Delphi文件操作

 unit unitFileOP;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
implementation
function GetSys32Dir:String;
var
Sys32Dir: string;
pSys32Dir: array[0..Max_Path] of char;
begin
GetSystemDirectory(pSys32Dir,Max_Pat ......

delphi中用ado连接oracle 10g

2009-12-01  00:41:35
之前安装了oracle 10g,后来为了在C#里面连接oracle,安装了ODAC,之后连接数据库时,填写数据库服务名,总是会出错,连接测试无法通过,不填数据库服务名,倒还可以通过连接测试
今晚终于查到原因了。。。
系统属性那里的环境变量,path这里,oracle的两个默认路径:
d:\oracle\product\10. ......

Delphi实现透明窗体

unit unitMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2 ......

delphi学习 字符串切割问题(split)

最近做一个项目,要用Delphi,以前从未学过,好是费劲啊,哈哈光是字符串切割这个问题就困扰了几个小时,通过查资料终于解决,在这与大家分享一下
Function split(src: pchar; ch: char):TStringList;
// 分割字符串
var
  i: Integer;
  tmp : string;
begin
  Result:=TStringList.Create;
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号