BLOB数据的问题,急!急!急!

sunyanbing 2003-05-07 02:27:23
各位大侠们,我现在正在做一个程序,数据库为ASA,库中的表TEST中有一个BLOB型的字段,我的想法是这样的,将表TEST中的其它字段的数据插入到一个WORD文件中的相应的书签中(这一步已经完成),然后将该WORD文件存入表TEST中的BLOB型的字段中,请问应该怎么来完成?还有存入BLOB型字段后,如何以WORD的形式再读出来?谢谢各位了!
...全文
20 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wang661 2003-05-09
dw_main.object.file_type[ll_row] = right(ls_file, 4),确定当前行所上传文件的类型。

ll_id = dw_main.object.oid_file[ll_row]这句可以去掉了。
回复
sunyanbing 2003-05-09
TO:WANG661
请问你有EMAIL吗?我们可以研究研究啊。
我的邮件是sunyanbing@ninetowns.com
回复
dengxun78 2003-05-08
GZ!
回复
sunyanbing 2003-05-07
TO:WANG661
dw_main.object.file_type[ll_row] = right(ls_file, 4)
ll_id = dw_main.object.oid_file[ll_row]
这几句是什么作用啊?另外我在打开文件时全是乱码,请问怎么处理啊?
回复
shahand 2003-05-07
创建一个oleobject变量 与word97的ole接口(Word.application)连接起来,打开文件,插入一些文字,保存,关闭
OLEObject 01; string s1;integer li_return
o1 = Create oleobject
li_return = o1.ConnectToNewObject("Word.application")
if li_return <> 0 then
destroy 01
messagebox('error','can't connect to Microsoft Word ErrorCode = '+String(li_return))
return
end if
o1.documents.open("C:\temp\temp.doc")
//令o1为可视的并显示ms word的用户名和文件
o1.Application.Visible = True
s1 = o1.UserName; MessageBox('Ms Word 用户名',s1)
s1 = o1.ActiveDocument.Name; MessageBox('Ms Word 文档名',s1)
//在一个新的段落插入一些文字
o1.Selection.TypeParagraph()
o1.Selection.typetext("插入这段文字")
o1.Selection.TypeParagraph()
//在第一个书签插入文字
o1.ActiveDocument.Bookmarks[1].Select
o1.Selection.TypeText("你好")
//在书签'End'处插入文字
o1.ActiveDocument.Bookmarks.Item("End").Select
o1.Selection.TypeText("再见")
o1.ActiveDocument.Save()
o1.Quit()
return
回复
shahand 2003-05-07
找到书签, 插入文字
OLEObject 01;
string s1;
o1 = Create oleobject
o1.ConnectToNewObject("Word.application")
o1.documents.open("C:\temp\temp.doc")....................
......................
o1.editgoto("address1")
o1.insert(s1)
//打印
o1.fileprint()
o1.fileclose(2)
//close
o1.DisconnectObject()
Destroy o1
回复
shahand 2003-05-07
这谁比我还能贴
回复
wang661 2003-05-07
//打开
oleobject lo_open
lo_open = create oleobject

int result
choose case upper(ls_type)
case '.XLS'
result = lo_open.ConnectToNewObject("excel.application")
if result = 0 then
lo_open.application.visible = 1
lo_open.Workbooks.open(ls_file);
end if

case '.DOC'
result = lo_open.ConnectToNewObject("word.application")
if result = 0 then

lo_open.documents.open(ls_file);
lo_open.application.visible = 1
//insert the audi to the file


else
destroy lo_open
messagebox('提示', '文件已经下载到:' + ls_file)
return
end if
case else
result = lo_open.ConnectToObject(ls_file)
if result = 0 then
lo_open.application.visible = 1
lo_open.application.open()
else
destroy lo_open
messagebox('提示', '文件已经下载到:' + ls_file)
return
end if
end choose

//lo_open.close();
//lo_open.disconnect();
destroy lo_open
回复
wang661 2003-05-07
//下载
//down load the file form the sever and open it
integer li_FileNum
blob lb_file, b
long ll_row
double ll_id
string ls_direct, ls_type, ls_file


// Set a wait cursor
SetPointer(HourGlass!)

//select the bolb
ll_row = dw_main.getrow()

ls_type = dw_main.object.file_type[ll_row]
if POS(ls_type, '.') <= 0 then
messagebox('提示', '此记录没有上载文件!')
return
end if

ll_id = dw_main.object.oid_file[ll_row]
SELECTBLOB blob字段
INTO :lb_file
FROM 表

USING sqlca;

//get the file's fullname, create it at the process's current directory and //named 'temp'
ls_direct = space(100)
GetCurrentDirectory(len(ls_direct), ls_direct)
ls_file = ls_direct + '\temp' + ls_type

//open it and write
li_FileNum = FileOpen( &
ls_file, &
StreamMode!, Write!, Shared!, Replace!)
long flen
int loops,i

flen = len(lb_file)


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
FOR i = 1 to loops
if i = loops then
b = lb_file
else
b = blobmid(lb_file,1,32765)
lb_file = blobmid(lb_file, 32766, len(lb_file) - 32765)
end if
Filewrite(li_FileNum, b) //tot_b = tot_b + b
NEXT
//FileWrite(li_FileNum, lb_file)
fileclose(li_filenum)

回复
wang661 2003-05-07
//上传
//upload the file to sever

//get the currentrow
long ll_row
ll_row = dw_main.getrow()
if ll_row <= 0 then
messagebox('提示','请选择上载文件的记录')
return
end if

//if new row the update it
if dw_main.GetItemStatus(ll_row, 0, Primary!) = New! or dw_main.GetItemStatus(ll_row, 0, Primary!) = NewModified! then
//dw_main.object.file_type[ll_row] = ' '
dw_main.accepttext()
if dw_main.update() = 1 then
commit;
//dw_main.resetupdate()
else
rollback;
return
end if
end if

//get the file name
string ls_file, named, ls_olddirect
integer value

//save the old directory
ls_olddirect = space(100)
GetCurrentDirectory(len(ls_olddirect), ls_olddirect)

value = GetFileOpenName("Select File", ls_file, named, "DOC", &
+ "Excle Files (*.XLS),*.XLS," &
+ "Doc Files (*.DOC),*.DOC," &
+ "All Files (*.*), *.*")
if value <> 1 then return

//reset the process's directory
SetCurrentDirectory(ls_olddirect)

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(ls_file)
li_FileNum = FileOpen(ls_file, &
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)

// Update the Blob
double ll_id
ll_id = dw_main.object.oid_file[ll_row]
sqlca.AutoCommit = true
UPDATEBLOB table SET blob字段 = :tot_b

USING sqlca;
IF sqlca.SQLNRows > 0 THEN
COMMIT USING sqlca ;
//set the file type
dw_main.object.file_type[ll_row] = right(ls_file, 4)
dw_main.update()
commit;
END IF
sqlca.AutoCommit = false
回复
juwuyi 2003-05-07
用ole控件。
回复
相关推荐
发帖
PowerBuilder
创建于2007-09-28

868

社区成员

PowerBuilder 相关问题讨论
申请成为版主
帖子事件
创建了帖子
2003-05-07 02:27
社区公告
暂无公告