高分求助!怎样把图片控件用jpg格式插入数据库!

JackY_Pend 2005-08-02 10:43:33
我用的是access数据库,请问在access里面插入图片保存的格式是哪种格式,而在PB里,怎样用代码插入!问题解决,立刻散分,Thank!
...全文
188 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
嘘嘘兔 2005-08-02
  • 打赏
  • 举报
回复
参考一下:

long ll_filelen
int li_filenum,li_loops,li_counter
blob lb_read,lb_picture
string ls_photofile='aaa.jpg',ls_no
ls_no=dw_1.getitemstring(dw_1.getrow(),'no')//取编号
ll_filelen=filelength(ls_photofile)
li_filenum=fileopen(ls_photofile,streammode!,read!,lockread!)

if ll_filelen > 32765 then
li_loops=((ll_filelen - 1)/32675)+1
else
li_loops=1
end if

for li_counter=1 to li_loops
fileread(li_filenum,lb_read)
lb_picture=lb_picture+lb_read
next
fileclose(li_filenum)



sqlca.autocommit=true
updateblob t_health
set picture=:lb_picture
where no = :ls_no;//保存图片
if sqlca.sqlnrows>0 then
commit;
else
rolback;
end if
嘘嘘兔 2005-08-02
  • 打赏
  • 举报
回复
参考一下:

long ll_filelen
int li_filenum,li_loops,li_counter
blob lb_read,lb_picture
string ls_photofile='aaa.jpg',ls_no
ls_no=dw_1.getitemstring(dw_1.getrow(),'no')//取编号
ll_filelen=filelength(ls_photofile)
li_filenum=fileopen(ls_photofile,streammode!,read!,lockread!)

if ll_filelen > 32765 then
li_loops=((ll_filelen - 1)/32675)+1
else
li_loops=1
end if

for li_counter=1 to li_loops
fileread(li_filenum,lb_read)
lb_picture=lb_picture+lb_read
next
fileclose(li_filenum)



sqlca.autocommit=true
updateblob t_health
set picture=:lb_picture
where no = :ls_no;//保存图片
if sqlca.sqlnrows>0 then
commit;
else
rolback;
end if
balloonman2002 2005-08-02
  • 打赏
  • 举报
回复
ACCESS可以用“备注”型字段,具体存取方法参考:
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=201309
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=204439
chj7942 2005-08-02
  • 打赏
  • 举报
回复
image (image 数据类型:在 Access 项目中,一种长度可变的数据类型,最多可存储 2^31 -1 (2,147,483,647) 字节的二进制数据。image 数据类型用来存储 BLOB(二进制大对象),如图片、文档、声音和已编译代码。)
rodgerwu 2005-08-02
  • 打赏
  • 举报
回复
blob {270000}bmp_photo
blob b_get_empty_photo
LONG V_FILEHANDLE,V_LENOFREAD
STRING V_HPHM,V_FILE_PATH,V_FILE_NAME
BLOB V_PHOTO,V_READED_PHOTO
BLOB {750000}V_PHOTO_BMP
INTEGER I
long temp_var

p_1.visible=true

//打开照片文件
V_FILEHANDLE = GetFileOpenName("选择相片文件", &
+ V_FILE_PATH, V_FILE_NAME, "JPG", &
+ "压缩图象文件 (*.JPG),*.JPG")

IF V_FILEHANDLE=1 THEN
IF Lower(Right(V_FILE_NAME,3)) = 'jpg' THEN
IF FileLength(V_FILE_NAME ) > 500 * 1000 Then
MessageBox("操作提示:","您选择的图片文件太大,不能存储!") ;
FileClose( V_FILEHANDLE ) ;
return
ELSE //READ PICTURE FILE
V_FILEHANDLE = fileOpen(V_FILE_NAME,streamMode!)
DO //READ PICTURE FILE TO BLOB
V_READED_PHOTO = Blob( "" ) ;
V_LENOFREAD = FileRead(V_FILEHANDLE,V_READED_PHOTO) ;
temp_var = temp_var + V_LENOFREAD
V_PHOTO= V_PHOTO + V_READED_PHOTO;
LOOP UNTIL V_LENOFREAD=-100
V_PHOTO_BMP = V_PHOTO

p_1.SETPICTURE(V_PHOTO_BMP)
b_get_empty_photo=V_PHOTO //JPG格式
End If
ELSE
MESSAGEBOX("图形格式出错:","请选择JPG图形文件格式!")
FileClose( V_FILEHANDLE ) ;
return
END IF
END IF

FileClose( V_FILEHANDLE ) ;

string ls_lsh,ls_xh
ls_xh=dw_1.getitemstring(dw_1.getrow(),"xh")
ls_lsh=dw_1.getitemstring(dw_1.getrow(),"lsh")
int li_count
select Count(*) into :li_count from t_temp_jszp where lsh = :ls_lsh;
IF li_count = 0 Then
INSERT INTO "T_TEMP_JSZP"
( "LSH","XSKH","XH","ZP" )
VALUES ( :ls_lsh,'',:ls_xh,'' ) ;

updateblob t_temp_jszp SET zp = :b_get_empty_photo
WHERE lsh=:ls_lsh ;
Else
updateblob t_temp_jszp SET zp = :b_get_empty_photo
WHERE lsh=:ls_lsh ;
End If
sun1976 2005-08-02
  • 打赏
  • 举报
回复
建议应用程序主路径建立一个专用文件夹,比如pic
而数据库中存放文件名称
打开的时候文件名称列拼出全路径,选中showaspicture

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧