button新增資料庫資料 |
答題得分者是:yubad2000
|
music1124
一般會員 發表:6 回覆:6 積分:2 註冊:2008-01-09 發送簡訊給我 |
請問一下!我把資料打在edit裡面然後我想按下button後完成加入這筆資料到我連結的資料庫呢
目前做到這裡卡住@@ 只完成了檢視資料: procedure TForm1.Button1Click(Sender: TObject); begin Table1.Databasename:='Dog99'; Table1.tablename:='dog1'; Table1.Active:=true; ShowMessage('筆數:' InttoStr(Table1.RecordCount) '筆!'); ShowMessage('項目::' InttoStr(Table1.FieldCount) '項!'); repeat edit1.text:= Table1['NAME']; edit2.text:= Table1['PRICE']; edit3.text:= Table1['QUANTITY']; edit4.Text:= Table1['PRICE']*Table1['QUANTITY']; Table1.next; ShowMessage('下一筆'); until Table1.Eof; end; |
yubad2000
中階會員 發表:0 回覆:44 積分:78 註冊:2007-09-30 發送簡訊給我 |
Table1.Append
then Table1['NAME']:=edit1.text; Table1['PRICE']:= edit2.text; ..... Table1.post.
------
===波士頓夜未眠=== What a wonderful world!! Jazz up the world with jazz!! ================== When I am not programming... you can find me here: http://www.holy-war.de/EN/World3/bin/?advertiser=63190 |
music1124
一般會員 發表:6 回覆:6 積分:2 註冊:2008-01-09 發送簡訊給我 |
可以再問一下!我可以將這個套用在刪除跟修改上嗎?
procedure TForm1.Button5Click(Sender: TObject); begin Table1.Databasename:='Dog99'; Table1.tablename:='dog1'; Table1.Active:=true; Table1.Delete; Table1['NAME']:=edit1.text; Table1['PRICE']:= edit2.text; Table1['QUANTITY']:=edit3.Text; Table1.post end; 她好像不會刪除我打的東西.. |
music1124
一般會員 發表:6 回覆:6 積分:2 註冊:2008-01-09 發送簡訊給我 |
|
ace33022
一般會員 發表:2 回覆:41 積分:23 註冊:2004-05-14 發送簡訊給我 |
===================引 用 music1124 文 章=================== 可以再問一下!我可以將這個套用在刪除跟修改上嗎? procedure TForm1.Button5Click(Sender: TObject); begin Table1.Databasename:='Dog99'; Table1.tablename:='dog1'; Table1.Active:=true; Table1.Delete; Table1.Edit; // 加這一行試試,Table元件很久沒用了。 Table1['NAME']:=edit1.text; Table1['PRICE']:= edit2.text; Table1['QUANTITY']:=edit3.Text; Table1.post end; 她好像不會刪除我打的東西.. |
music1124
一般會員 發表:6 回覆:6 積分:2 註冊:2008-01-09 發送簡訊給我 |
|
yubad2000
中階會員 發表:0 回覆:44 積分:78 註冊:2007-09-30 發送簡訊給我 |
Yes, you can use the same code for delete, and edit. But, They do not have the same behavior as append.
First, you have to move "record pointer" to the location of the record will be modified by using .next or .locate. Second, use .edit and then .post for editing. Be careful with .delete, it will delete the pointed record immediately without any warning. After the delete, you have to clear out the edit.text's vaule by yourself. ===================引 用 music1124 文 章=================== 可以再問一下!我可以將這個套用在刪除跟修改上嗎? procedure TForm1.Button5Click(Sender: TObject); begin Table1.Databasename:='Dog99'; Table1.tablename:='dog1'; Table1.Active:=true; Table1.Delete; Table1['NAME']:=edit1.text; Table1['PRICE']:= edit2.text; Table1['QUANTITY']:=edit3.Text; Table1.post end; 她好像不會刪除我打的東西..
------
===波士頓夜未眠=== What a wonderful world!! Jazz up the world with jazz!! ================== When I am not programming... you can find me here: http://www.holy-war.de/EN/World3/bin/?advertiser=63190 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |