線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1874
推到 Plurk!
推到 Facebook!

同時使用DBE 和ADO會有問題嗎

尚未結案
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-07 14:43:46 IP:220.130.xxx.xxx 未訂閱
我原本是用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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-07 15:11:35 IP:61.222.xxx.xxx 未訂閱
建議全部更換為 ADO 吧! BDE 使用 TDatabase,ADO 使用為 ADOConnection 基本上是可以同時使用,佔用資源不說,不過這樣做有什麼意義! BDE 目前已停止維護。不會有新的版本。 雖然 ADO 效率比BDE 差一些。 但是使用 ADO 還是比較有前途的。
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-08 01:34:23 IP:61.223.xxx.xxx 未訂閱
謝謝wameng前輩的回應 其實我也很想換成ADO 只是現在中毒太深 轉換的工程太大... 就算我肯,時間也不允許...    救命啊~~~~ 有沒有DBE轉ADO的斧底抽薪之計... /> 如果沒有
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-11-08 02:03:07 IP:61.223.xxx.xxx 未訂閱
以下是我把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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-11-08 02:39:01 IP:218.170.xxx.xxx 未訂閱
抬個槓,DBE應該是BDE吧,看了覺得有點怪...
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-11-08 09:37:03 IP:220.130.xxx.xxx 未訂閱
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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-11-08 10:51:10 IP:61.222.xxx.xxx 未訂閱
引言: 以下是我把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真不知道該怎麼活
這樣改很正確啊!我就是這樣修改的。 直接修改 PAS 及 DFM。
zshlf
一般會員


發表:18
回覆:11
積分:5
註冊:2003-06-03

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-11-08 11:48:59 IP:61.142.xxx.xxx 未訂閱
引言: 我原本是用DBE連SQL Server 本來因為DBE無法取得recno所以改用ClientDataSet 可是ClientDataSet用起來常常會有問題 主要可能是它把資料先cache在client端吧 所以刪除資料要applyupdate 新增資料後要refresh才能再新增 我怕這樣沒完沒了 所以想將部份的DBE Table改用ADO Table 不知道有人有共用過嗎 同時使用兩種Table元件會有問題嗎? K.Top是我見過最棒的程式社群
如果沒有K.Top真不知道該怎麼活
我也碰到这个问题,权衡后选择了clientdataset.不过我也试过同时用两种table,问题不大。只是多了一个连接,消耗更多资源。 1 如果在程序中用了cacheUpdate控件,在ado中没有类似的控件,难以通过把ttable 改为 tadotable 来实现 2 使用clientdataset 可以为将来升级为多层结构打下基础 3 屏蔽了数据引擎,可以考虑dbexpress等单方向数据集,减轻服务器的负担 4 最重要的是,你可以慢慢替换所有的模块,降低风险。
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-11-09 14:04:19 IP:220.130.xxx.xxx 未訂閱
唉呀呀~~~~ 聽完兩位大大的指導... 更不知道該選怎麼做了....    K.Top是我見過最棒的程式社群
如果沒有K.Top真不知道該怎麼活
系統時間:2024-08-09 1:29:42
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!