在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
相关文档:
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 ......
关于IntraWeb程序在编译时出现错误的解决方法
错误提示:[Error] IWLicenseKey.pas(12): Undeclared identifier: 'SetLicenseKey'
处理方法:进入菜单Tools->Environment Options,选择‘Library’,将'Library path'参数中有关intraweb的目录放在前面即可。
使用&n ......
http://developer.51cto.com/art/200510/7205.htm
[DELPHI]网络邻居复制文件
uses shellapi;
copyfile(pchar('newfile.txt'),pchar('//computername/direction/targer.txt'),false);
[DELPHI]产生鼠标拖动效果
通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL:
var xpanel,ypanel,xlabel,yla ......
delphi中application.processmessages的作用
procedure TForm1.Button2Click(Sender: TObject);
var
I, J, X, Y: Word;
begin
I := 0;
J := 0;
while I < 64000 do
begin
Randomize;
& ......
1) Delphi向oracle中传递参数 如oracle中的参数名为erpcx
答:如果想从表里取值到oracle,则erpcx:=trim(aq1.fieldbyname('erpcx').AsString);
否则直接用控件名字
语句为
with aperp do
begin
connection:=dm.ADOCerp;
parameters.Clear;&nbs ......