GetFileOpenName("請選擇插入文件",filepath,filename,"doc","選擇文件(*.*), *.*")
If Len(filepath)=0 Then
Return
End If
long row
row=dw_1.insertrow(dw_1.rowcount()+1)
dw_1.setitem(row,"cou_id",jb)
dw_1.setitem(row,"sort1",filename)
dw_1.scrolltorow(row)
dw_1.setrow(row)
dw_1.setfocus()
if dw_1.update()=1 then
commit using sqlca;
else
rollback using sqlca;
end if
setpointer(arrow!)
ll_row=dw_1.getrow()
aa=string(dw_1.object.cou_id[ll_row])
bb=string(dw_1.object.id[ll_row])
If ole_1.InsertFile(filepath)<>0 Then
Return
End If
Blb_tmp=ole_1.ObjectData
UPDATEBLOB tms_cou_image SET book=:blb_tmp
WHERE cou_id=:aa and id=:bb
USING SQLCA;
請問有沒有別的方法把PPT或EXCEL存入到數據庫中,或者可以幫我優化一下我的語句,謝謝!
------解决方案--------------------
不知你要做什么,又是保存,又是读取,又是保存的!
可改成
long row
row=dw_1.insertrow(0)
dw_1.setitem(row,"cou_id",jb)
dw_1.setitem(row,"sort1",filename)
bb=string(dw_1.object.id[row])
if dw_1.update()=1 then
UPDATEBLOB tms_cou_image SET book=:blb_tmp
WHERE cou_id=:jb and id=:bb ;
if sqlca.sqlcode = 0 then
commit using sqlca;
else
rollback using sqlca;
end if
else
rollback using sqlca;
end if
------解决方案--------------------
把那句加上了,也可以直接读取文件
GetFileOpenName("請選擇插入文件",filepath,filename,"doc","選擇文件(*.*), *.*")
If Len(filepath)=0 Then
Return
End If
///////////////OLE方式
If ole_1.InsertFile(filepath) <>0 Then
Return
End If
Blb_tmp=ole_1.ObjectData
/////PB帮助中的例子!改下就行了!直接读取文件
integer li_FileNum, loops, i
long flen, bytes_read, new_pos
blob b, tot_b
// Set a wait cursor
SetPointer(HourGlass!)
// Get the file length, and open the file
flen = FileLength(sle_filename.Text)
li_FileNum = FileOpen(sle_filename.Text, &
StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/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)
/////////////////////////
long row
row=dw_1.insertrow(0)
dw_1.setitem(row,"cou_id",jb)
dw_1.setitem(row,"sort1",filename)
bb=string(dw_1.object.id[row])
if dw_1.update()=1 then
UPDATEBLOB tms_cou_image SET book=:blb_tmp
WHERE cou_id=:jb and id=:bb ;
if sqlca.sqlcode = 0 then
commit using sqlca;
else
rollback using sqlca;
end if
else
rollback using sqlca;
end if