// บันทึกรูปภาพไปยังฐานข้อมูล
ฟังก์ชั่น imagesavetosql (ชุดข้อมูล: tQuery; ชื่อไฟล์: สตริง): บูลีน;
วาจา
ImageJPG: tjpegimage;
Mystm: tmemorystream;
เริ่ม
ผลลัพธ์: = เท็จ;
mystm: = tmemorystream.create;
imagejpg: = tjpegimage.create;
ถ้าชื่อไฟล์ <> '' แล้ว
เริ่ม
imagejpg.loadfromfile (ชื่อไฟล์);
Imagejpg.savetostream (mystm);
mystm.position: = 0;
tblobfield (dataset.fieldbyname ('pict')). loadfromstream (mystm);
ผลลัพธ์: = จริง;
จบ;
mystm.free;
Imagejpg.free;
จบ;
// เพิ่ม tdirectorylistbox และ tgauge control บนอินเทอร์เฟซ
ขั้นตอน tfrmpict.bitbtn2click (ผู้ส่ง: tobject);
วาจา
Dirlist: TSTRINGLIST;
ฉัน: จำนวนเต็ม;
เริ่ม
สืบทอด;
ถ้า chk_road. ตรวจสอบแล้ว
เริ่ม
dirlist: = tstringlist.create;
dirlist.clear;
พยายาม
getAllfileName (DirectoryListBox1.Directory, Dirlist);
ถ้า dirlist.count> 0 แล้ว
เริ่ม
GAUGE1.MINVALUE: = 0;
GAUGE1.MAXVALUE: = DirList.Count-1;
สำหรับ i: = 0 ถึง dirlist.count-1 ทำ
เริ่ม
ด้วย dm.qry_pict ทำ
เริ่ม
แทรก;
ฟิลด์ [0] .ASTSTRING: = COPY (dirlist.strings [i], 1, pos ('.', dirlist.strings [i])-1);
ถ้า imagesavetosql (dm.qry_pict, dirlist.strings [i]) = false แล้ว
เริ่ม
ShowMessage ('นำเข้า'+dirlist.strings [i]+'. jpg image arror');
ยกเลิก;
จบ;
โพสต์;
สิ้นสุด; //
GAUGE1.AddProgress (1);
สิ้นสุด; // สำหรับ
สิ้นสุด // ถ้า
อื่น
ShowMessage ('ไม่มีรูปภาพประเภท JPG ในไดเรกทอรีนี้');
ในที่สุด
dirlist.free;
จบ;
จบ
อื่น
ShowMessage ('โปรดดำเนินการเลือกเส้นทาง');
//ปิด;
จบ;