查看!!!有点问题
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
添加!!!!!!!!
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