使用的方法如下:
以下功能除了選擇相片功能可以實作,另外2個都沒有效果,麻煩各位幫忙看下,謝謝。
表里有3個欄位。ygbm char(10),ygxm char(10),photo varbinary
在按扭選擇相片中代碼如下
string ls_pathname, ls_filename
integer li_value,li_FileNum,loops,i
long ll_fileLength,bytes_read,new_pos
li_value = GetFileOpenName("選擇照片", &
+ ls_pathname, ls_filename, "jpg","Jpg Files (*.jpg),*.jpg")
IF li_value = 1 THEN
// Set a wait cursor
SetPointer(HourGlass!)
// Get the file length, and open the file
ll_fileLength= FileLength(ls_filename) //得到檔案名的長度
li_FileNum = FileOpen(ls_filename, &
StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF ll_filelength > 32765 THEN
IF Mod(ll_filelength, 32765) = 0 THEN
loops =ll_filelength/32765
ELSE
loops = (ll_filelength/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
FileClose(li_FileNum)
P_1.setpicture(tot_b)
Elseif li_value=https://bbs.csdn.net/topics/-1 then
MessageBox("選擇照片","打開檔案錯誤!")
End If
保存功能如下
dw_1.accepttext()
dw_1.update()
commit;
string ls_ygbh
ls_ygbh=dw_1.object.ygbm[dw_1.getrow()]
UPDATEBLOB ygzl SET photo = :tot_b
WHERE ygbm = :ls_ygbh
USING sqlca;
IF sqlca.SQLNRows <> 0 THEN
messagebox("提示","沒的資料")
else
COMMIT USING sqlca ;
END IF
還有一個是在資料視窗里的itemchanged事件下寫的
choose case dwo.name
case 'ygbm'
string ls_ygxm,ls_ygbh2
ls_ygbh2=dw_1.getitemstring(sa1,"ygbm")
messagebox("",string(ls_ygbh2))
select ygxm into:ls_ygxm from ygzl where ygbm=:ls_ygbh2;
// messagebox("",string(ls_ygxm))
if sqlca.sqlcode<>0 then
messagebox("提示",sqlca.sqlerrtext)
return
else
dw_1.object.ygxm[row]=ls_ygxm
end if
Blob Emp_id_pic
SELECTBLOB photo
INTO :Emp_id_pic
FROM ygzl
WHERE ygbm = :ls_ygbh2
USING sqlca ;
p_1.SetPicture(Emp_id_pic)
end choose
uj5u.com熱心網友回復:
哥們兒,你的代碼我看過了,沒什么問題,我甚至還試了一下update,也可以,只不過我用Oracle和寫字板檔案而已。你說selectblob不可用,你確定資料庫里有資料嗎?至于updateblob,它所在的行已經被插入了嗎?也許說的是廢話,不過從我得到的資訊來看只能給出這些建議了:)轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/117877.html
標籤:數據庫相關
下一篇:新人求救:excel匯入資料庫
