把一份WORD文档(含图片和表格)保存到MS SQL SERVER数据库中,用数据窗口保存和查看???

hykz 2001-06-05 03:32:00
我想把一份WORD文档(含图片和表格)保存到MS SQL SERVER数据库中,用数据窗口保存和查看???数据表结构为:
(id int not null primary key),
(title char(60) not null),
(docbody txt).
如果用富文本框可以实现吗?
...全文
346 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
sclt 2001-09-18
  • 打赏
  • 举报
回复
up
eastseaofdragon 2001-09-18
  • 打赏
  • 举报
回复
gz
hegum 2001-09-18
  • 打赏
  • 举报
回复
查看!!!有点问题
int ls_title
blob ole_blob,b
integer li_FileNum,loops,i,li_re
oleobject oleChild,lo_1
int result
long flen

If row <=0 Then return
this.selectrow(0, false)
this.selectrow(row, true)
ls_title = this.object.bh[row]
sqlca.autocommit=true
SELECT bh,gcmc
INTO :sle_bh.text,
:sle_name.text
FROM gonggao
WHERE bh = :ls_title;
if SQLCA.SQLCode = -1 then
MessageBox("SQL error",SQLCA.SQLErrText,Information!)
return -1
end if
commit;

selectblob gonggao into :ole_blob from gonggao
where bh =:ls_title;
if SQLCA.SQLCode = -1 then
MessageBox("SQL error",SQLCA.SQLErrText,Information!)
return -1
end if
commit;
//ole_1.objectdata=ole_blob

flen = Len(ole_blob)
messagebox("fg",flen)
li_FileNum = FileOpen("d:\d.doc",StreamMode!, Write!, LockWrite!,Replace!)
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
FOR i = 1 to loops
b = blobmid(ole_blob,32765 * (i - 1) + 1,32765)
li_re=FileWrite(li_FileNum, b)
NEXT
ELSE
li_re=FileWrite(li_FileNum, ole_blob)
END IF
FileClose(li_FileNum)
ole_1.insertfile("d:\d.doc")//**********
//lo_1 = create oleobject
//oleChild = create oleobject
//result=lo_1.connecttonewobject("word.application")
//oleChild.SetAutomationPointer(lo_1 )
//oleChild.documents.open("d:\d.doc")
// if result = 0 then
// oleChild.application.visible = true
// end if
//////end if
//destroy oleChild
//destroy lo_1

sqlca.autocommit=false
hegum 2001-09-18
  • 打赏
  • 举报
回复
添加!!!!!!!!
integer li_fl,li_FileNum, loops, i
string filepath,filename,docname,named,b2
blob ole_blob
blob tot_b,b
long flen ,bytes_read, new_pos
if sle_bh.text="" and sle_name.text="" then
messagebox("请输入编号和工程名称","确定")
return
end if
b2=trim(sle_bh.text)
GetFileOpenName("选择文件", docname, named, "*", + "Doc Files (*.*),*.*")
SetPointer(HourGlass!)
tot_b = b
flen = FileLength(docname)
messagebox("l",flen)
li_FileNum = FileOpen(docname,StreamMode!, Read!, LockRead!)
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
new_pos=1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
flen = len(tot_b)
messagebox("bd",len(tot_b))
FileClose(li_FileNum)
SQLCA.AutoCommit = True
string sql
sql= "INSERT INTO gonggao (bh,gonggao,gcmc) VALUES ("&
+trim(sle_bh.text)+",'','"&
+sle_name.text+"')"
EXECUTE IMMEDIATE :sql;
If SQLCA.SQLDBCode=0 Then
COMMIT USING SQLCA;
Else
MessageBox("数据库错误","插入失败")
ROLLBACK USING SQLCA;
Return
End If
If ole_1.InsertFile(docname)<>0 Then
Return
End If
UPDATEBLOB gonggao SET gonggao=:tot_b
WHERE bh=:b2;
if SQLCA.SQLCode = -1 then
MessageBox("SQL error",SQLCA.SQLErrText,Information!)
return -1
end if
commit;
////commit using sqlca;
//IF SQLCA.SQLNRows > 0 THEN
//COMMIT USING SQLCA ;
//messagebox("成功",len(tot_b))
////selectblob gonggao.gonggao into :ole_blob from gonggao
////where bh=:sle_bh.text;
////
//// messagebox("d",len(ole_blob))//&&&&&&&&&&&
dw_1.Retrieve()
ole_1.Activate(Offsite!)
// ELSE
// ROLLBACK USING SQLCA;
// MessageBox("数据库错误","插入失败")
// END IF
SQLCA.AutoCommit = false
sqlone 2001-07-06
  • 打赏
  • 举报
回复
RICHTEXT 控件,OLE,PB自带的例子中有
wangsw 2001-07-06
  • 打赏
  • 举报
回复
用BIN类型,当然是DOC控件了!!
装了WORD就会有的!
hykz 2001-06-05
  • 打赏
  • 举报
回复
能否说详细点啊兄弟,怎么读DOC的内容,文件长度有限制没有?我用的是MS SQL SERVER 7。0
,似乎没有blob数据类型,有binary和bit类型。保存了又如何还原成DOC显示啊,用什么控件显示。OLE我没做过,能否说明白点??谢谢。
tanye 2001-06-05
  • 打赏
  • 举报
回复
blob lb_doc
Selectblob docbody into lb_doc from ..

ole_1.object = lb_doc
xingxing 2001-06-05
  • 打赏
  • 举报
回复
当然可以的。
你先建立一个表,然后读出你的*.doc内容到一个blob中,把它保存到你的数据窗口就可以了嘛!!!
pbworm 2001-06-05
  • 打赏
  • 举报
回复
好象不可以作到吧。
最起码我不会。
Methodor 2001-06-05
  • 打赏
  • 举报
回复
RTF可以-效果不太好~~
建议用OLE-BLOB~~
am2000 2001-06-05
  • 打赏
  • 举报
回复
没有做不到的,只有想不到的...

754

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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