關於資料庫開發

2021-03-31 17:55:03 字數 1569 閱讀 3074

開發資料庫應用程式,delphi是當之無愧的好!我簡直是愛死她了

我在delphi入門與精通上看到乙個東東,開始沒在意,後來變通一下,嘿嘿……很實用哦

在我現在開發的應用程式中,沒乙個不用它的,方便快捷……

作用:編碼->名稱解釋**換不受字段長度限制),有很多方法,諸如:用lookupfield或直接用sql或用canvas等,但我用的是tfields的ongettext方法,呵呵……也許有哪位仁兄用過,這裡再提提加深一點印象哈

是這樣的:

假設我有乙個主表(employee:員工表)和乙個編碼表(bmzw:職務)

employee:

xm-----員工姓名

zw-----職務

……………………

bmzw:

bm-----職務編碼

mc-----職務漢字說明

現在我們要做的是查詢所有員工的情況(employee),職務**(zw)使用者肯定讀不懂,所以怎樣把employee中的zw欄位顯示成bmzw中bm欄位相對應的mc欄位內容呢?

我的解決方法是這樣的:

//------query1:查詢主表      query2:查詢編碼表

//------button1:查詢

//查詢編碼表

procedure tform1.formcreate(sender: tobject);

begin

query1.fieldbyname('zw').ongettext:=query1zwgettext;//**********//

query2.close;

query2.sql.text:='select * from bmzw';

queyr2.open;

end;

//***釋放

procedure tform1.formdestroy(sender: tobject);

begin

query1.fieldbyname('zw').ongettext:=nil;

end;

//查詢主表

procedure tform1.button1click(sender: tobject);

begin

query1.close;

query1.sql.text:='select * from employee';

query1.open;

end;

//ongetext過程(employee.zw->bmzw.mc)

procedure tform1.query1zwgettext(sender: tfield; var text: string;

displaytext: boolean);

begin

//此處是關鍵

if query2.locate('bm',sender.asstring,) then  

text:=query2.fieldbyname('mc').asstring

else

text:=sender.asstring;

end;

暫時就這麼多了,趕快試試吧……可能講的不清楚,過段時間再說,並且把所有的方法都寫上

關於資料庫

在dao檔案下 第一步 public static void main string args 定義四個私有的全域性靜態變數 第二步 1.以增加一條新聞為例 增加一條新聞 param news return public boolean insertnews news news ps.close c...

關於資料庫

一 資料庫的基本操作 建立 creat database 資料庫名 避免重複資料庫 if not exists 資料庫名 檢視建庫語句 show creat database 資料庫名 查詢所有資料庫 show databases 使用 use 資料庫名 刪除資料庫 drop database 資料...

關於資料庫

1.mysql有哪兩個主要的儲存引擎 區別呢?2.儲存過程與儲存函式的區別?3.資料庫的優化 羅列一些 三.資料庫優化補充 4.快取優化 以mysql為例 資料庫自身查詢快取 my.ini query cache type query cache size 查詢快取命中 show status li...