UniDAC使用日记

上传人:桔**** 文档编号:488997313 上传时间:2022-10-24 格式:DOC 页数:15 大小:166.50KB
返回 下载 相关 举报
UniDAC使用日记_第1页
第1页 / 共15页
UniDAC使用日记_第2页
第2页 / 共15页
UniDAC使用日记_第3页
第3页 / 共15页
UniDAC使用日记_第4页
第4页 / 共15页
UniDAC使用日记_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《UniDAC使用日记》由会员分享,可在线阅读,更多相关《UniDAC使用日记(15页珍藏版)》请在金锄头文库上搜索。

1、UniDAC使用日记1. UniQuery默认状态为行提交,使用前根据需要设置readonly或cachedupdates属性2. UniQuery.Filter默认大小写区分,请注意设置FilterOptions属性(foCaseInsensitive),TVirtualtable也存在相同情况3. UniQuery默认情况下,有些varchar类型的字段有自动加了一个空格,请注意设置Options.TrimVarChar=true4. UniQuery在进行Insert时,若字段不能为null且前台操作未填写时,可能会报错,请设置RequiredFields=true5. UniQuery

2、在修改数据集时,默认的方式是按关键字生成SQL语句进行数据提交。还有另外两种方式:一是设置updateSQL,一是设置KeyFields(具体请sql跟踪查看)6. UniQuery的数据排序属性是IndexFieldNames7. 数据提交的顺序,一定要注意: with MyQuery do begin Session.StartTransaction; try . Modify data ApplyUpdates; try to write the updates to the database Session.Commit; on success, commit the changes

3、except RestoreUpdates; restore update result for applied records Session.Rollback; on failure, undo the changes raise; raise the exception to prevent a call to CommitUpdates! end; CommitUpdates; on success, clear the cacheend;对于单数据集的提交:MyQuery. ApplyUpdates;MyQuery. CommitUpdates;8. DataM中提供了一个功能Clo

4、ne(Source, Dest):一、Dest是TVirtualTable,则完整的将源数据集复制;二、Dest是UniQuery,则是将Source的SQL复制到Dest,并Open9. UniQuery.SetReadOnly属性说明1) 我们经常会用到多表关联,且需要在前台修改数据。举个例子:a表和b表,在前台两个表字段都需要修改,则需要将SetReadOnly设置成false2) 特别注意:若将一个UniQuery.SetReadOnly设置成true,而这个表有一个自增长ID,那么你在提交数据时会出错,跟踪SQL会发现,ID被前台前行传了一个null值10UniQuery. Refr

5、eshRecord,可以刷新当前选择的数据11我们经常会在UniQuery的SQL定义一些参数,在传参时,需要特别注意,例如:QExec.Close;QExec.SQL.Text:= select * from YHB where sYHBH=:P_YHBH;在传参时有两种写法1)最稳妥的写法QExec. ParamByName(P_YHBH).DataType:= ftString;QExec. ParamByName(P_YHBH).ParamType:= ptInPut;QExec. ParamByName(P_YHBH).AsString:= 张三;(此处可将AsString换成Val

6、ue)2)下面这个写法我做了简单测试,也是可以的,但对复杂的SQL传参是否正确,未知QExec. ParamByName(P_YHBH).AsString:= 张三;(在不对参数的数据类型和传入传出类型进行指定的情况下,绝对不能使用Value) UniDAC的过程中一定要注意,在DataM中提供了一个函数PrepareParam,请注意看一下。在ADO12Sybase的一个特性update a set a.fSJ=b.fSJfrom table1 a join table2 b on a.sYPBSM=b.sYPBSM上述SQL语句在Sybase下执行不能通过,请改写成如下SQL(在MS和AS

7、E中都能执行通过)update table1 set fSJ=b.fSJfrom table1 a join table2 b on a.sYPBSM=b.sYPBSMUniDAC官方网址:http:/ to Database1、 通用连接属性l Provider 第一个就应该设置的属性,指定要连接的数据库类型,根据指定的数据库连接类型不同其它的设置也会发生相应的变化;l Username and Password 登录数据的有效用户名和密码;l Server 通常将此设成要连接数据库所在的计算机名或IP地址,如果将此属性设置为空,对于MySQL, InterBase连接数据库方式, UniD

8、AC 将试图连接本地(Localhost)。Oracle:客户端模式下,指定的Server名称一定要出现在tnsnames.ora中,且有效,设置效果如下: with UniConnection1 do begin ProviderName := Oracle; Server := ORCL; Username := username; Password := password; end;直连模式(Direct mode)下:在此模式下,运行软件的计算机可以不安装Oracle客户端而连接Oracle数据库,但要做以下设置:1) 设置直连模式2) 设置Server指定Server格式:Host:

9、Port:SID.注:客户端模式和直连模式的设置不能混淆,否则无法执行。两种格式严格区分。效果如下: with UniConnection1 do begin ProviderName := Oracle; Server := 192.168.1.113:1521:ORCL; Username := Username ; Password := Password 3; end;SQL Server:指定要连接的数据库所在的网络IP,且有效,如果采用的不是默认端口(1433),Server应该这样设置:HostName,PortNumber.l Database 这个属性只对SQL Server

10、, MySQL, PostgreSQL, InterBase, and SQLite 连接方式有效, l Port 指定TCP/IP协议访问的有效端口MySQL 默认端口 3306PostgreSQL -默认端口5432二、UniDAC(版本:2.7)连接数据库必要文件或局限需求1、Oracle连接Oracle在采用直连模式将受到以下限制:特别要注意的是(包括:应用TUniLoader):1)、应用直连模式,本地执行程序的客户机必须要安装TCP/IP协议2)、注意防火墙3)、数据库的triggers、check constraints、clustered tables、loading of r

11、emote objects、user-defined types将得不到支持4)、available, like OBJECT, ARRAY, REF, XML, BINARY_DOUBLE, BINARY_FLOAT这些类型将变为不可用5)、TUniLoader的应用版本应高于Oracle client 8.17以下是英文原文:l triggers are not supported l check constraints are not supported l referential integrity constraints are not supported l clustered t

12、ables are not supported l loading of remote objects is not supported l user-defined types are not supported l LOBs must be specified after all scalar columns l LONGs must be specified last l You cannot use TUniLoader in a threaded OCI environment with Oracle client 8.17 or lower. l Connect using the

13、 TCP/IP network protocol only. l Some types are not available, like OBJECT, ARRAY, REF, XML, BINARY_DOUBLE, BINARY_FLOAT. l Certain problems may occur when using firewalls. l NLS conversion on the client side is not supported. l Transparent Application Failover is not supported. l Statement caching

14、is not available. l OS authentication and changing expired passwords features are not available. l The DES authentication is used. l Oracle Advanced Security is not supported. l We do not guarantee stability of multithreaded applications. It is highly recommended to use the separate TUniConnection component for each thread when using UniDAC from different threads. 2、 SQL Server连接1) 提供连接支持服务端: SQL Server 2005 (including Compact and Express editions), SQL Server 2000, SQL Server 7, and MSDE. 客户端: SQL OLE DB and

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号