同時使用DBE 和ADO會有問題嗎 |
尚未結案
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
我原本是用DBE連SQL Server
本來因為DBE無法取得recno所以改用ClientDataSet
可是ClientDataSet用起來常常會有問題
主要可能是它把資料先cache在client端吧
所以刪除資料要applyupdate
新增資料後要refresh才能再新增 我怕這樣沒完沒了
所以想將部份的DBE Table改用ADO Table
不知道有人有共用過嗎
同時使用兩種Table元件會有問題嗎? K.Top是我見過最棒的程式社群
如果沒有K.Top真不知道該怎麼活 |
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
以下是我把DBE轉成ado的做法
若有一個名叫Table1的DBE Ttable元件
則找到在.dfm檔中Table1的定義,如下
object Table1: TTable DatabaseName = 'dbnTest' TableName = 'dbo.Order' Left = 144 Top = 184 object Table2Sn: TIntegerField FieldName = 'Sn' Required = True end object Table2Type: TStringField FieldName = 'Type' Size = 50 end object Table2Rank: TIntegerField FieldName = 'Rank' end object Table2Value: TStringField FieldName = 'Value' Size = 50 end end將 則找到在.dfm檔中Table1的定義,如下 object Table1: TTable DatabaseName = 'dbnTest'改成 object Table1: TADOTable Connection = dmConn.ADOConnectionTest CursorType = ctStatic接著在.pas檔找到Table的宣告,如下: 將 Table1: TTable;改成 Table1: TADOTable;重新編譯...竟然可以過 不知道有沒有人這樣做過.... 請多多指導.... 但是DBE和ADO在參數和Filter的用法不太一樣 這個就要自己個別改 K.Top是我見過最棒的程式社群 如果沒有K.Top真不知道該怎麼活 |
hahalin
版主 發表:295 回覆:1698 積分:823 註冊:2002-04-14 發送簡訊給我 |
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
From:http://www.delphi3000.com/ When you consider to migrate your existing paradox application to ADO there are a few things that your should keep in mind. 1. Delphi 5 Update
Under all circumstances you should get a copy of the Delphi 1 Update Pack. This update eliminates quite a few problems. 2. Using TADOTable or TADOQuery
Forget about TADOTable. In most cases consider using TADOQuery instead. Your master detail relationships will work much better using TADOQuery. TADOTable has problems with server side cursor (under Access). When setting up master detail relationships Delphi will set the IndexFieldNames property. With this property set to anything except '' you won't be able to open the table anymore. You could delete this property but Delphi would set it again next time you open the Table. When using TADOTable make sure that the TableDirect Property is set to TRUE otherwise any sorting order will be ignored. 3. Using server side or client side cursor?
If the number of records in your table is limited (i would say no more than 1000 records) you should use client side cursor. Otherwise using client side cursor will be unacceptable. The time for loading and even opening the table is extremely high because delphi fetches ALL records and caches it on your local machine. Unfortunately client side cursors are much more flexible. 4. Creation order
For master detail relationships always create the master table / query first. Otherwise the detail table will not be updated at runtime. 5. Parameters
Using parameters with ADO is not much fun. Instead of writing TableABC.ParamByName('CUSTNO').AsInteger := Anything write TableABC.Parameters.ParamValues['CUSTNO'] := Anything. In addition if you would like to modify your SQL-Query within your sourcecode don't forget to add Parameters.ParseSQL(TableABC.SQL.Text,TRUE); Otherwise you will get an error message telling you the the parameter could not be found.
You parameter name (corrosponding to a field in the master table) should be different from any field name in the detail table. master (table customer): NR
CUSTNO
NAME
... detail (table order): NR
CUSTNO
ORDERNO
... detail sql: select * from order where CUSTNO = :NO; This is fine with paradox. Using ADO the NR-field of the detail table will set set to the same value as the NR-field of the master table (customer). You will only get an error message if the primary key nr in the master table already exists in the detail table. Inserting records, especially in complex master detail relationships, will take more time than in paradox. However querys will open much faster even if you do not have indices for the selected field in your order clause. K.Top是我見過最棒的程式社群
如果沒有K.Top真不知道該怎麼活 |
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
引言: 以下是我把DBE轉成ado的做法 若有一個名叫Table1的DBE Ttable元件 則找到在.dfm檔中Table1的定義,如下這樣改很正確啊!我就是這樣修改的。 直接修改 PAS 及 DFM。object Table1: TTable DatabaseName = 'dbnTest' TableName = 'dbo.Order' Left = 144 Top = 184 object Table2Sn: TIntegerField FieldName = 'Sn' Required = True end object Table2Type: TStringField FieldName = 'Type' Size = 50 end object Table2Rank: TIntegerField FieldName = 'Rank' end object Table2Value: TStringField FieldName = 'Value' Size = 50 end end將 則找到在.dfm檔中Table1的定義,如下object Table1: TTable DatabaseName = 'dbnTest'改成object Table1: TADOTable Connection = dmConn.ADOConnectionTest CursorType = ctStatic接著在.pas檔找到Table的宣告,如下: 將Table1: TTable;改成Table1: TADOTable;重新編譯...竟然可以過 不知道有沒有人這樣做過.... 請多多指導.... 但是DBE和ADO在參數和Filter的用法不太一樣 這個就要自己個別改 K.Top是我見過最棒的程式社群 |
zshlf
一般會員 發表:18 回覆:11 積分:5 註冊:2003-06-03 發送簡訊給我 |
引言: 我原本是用DBE連SQL Server 本來因為DBE無法取得recno所以改用ClientDataSet 可是ClientDataSet用起來常常會有問題 主要可能是它把資料先cache在client端吧 所以刪除資料要applyupdate 新增資料後要refresh才能再新增 我怕這樣沒完沒了 所以想將部份的DBE Table改用ADO Table 不知道有人有共用過嗎 同時使用兩種Table元件會有問題嗎? K.Top是我見過最棒的程式社群我也碰到这个问题,权衡后选择了clientdataset.不过我也试过同时用两种table,问题不大。只是多了一个连接,消耗更多资源。 1 如果在程序中用了cacheUpdate控件,在ado中没有类似的控件,难以通过把ttable 改为 tadotable 来实现 2 使用clientdataset 可以为将来升级为多层结构打下基础 3 屏蔽了数据引擎,可以考虑dbexpress等单方向数据集,减轻服务器的负担 4 最重要的是,你可以慢慢替换所有的模块,降低风险。 |
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |