>>程云
以下一个是保存到数据库,一个是从数据库中调出
我使用的是 ORACLE数据库,XKRTXAQCS 的数据类型是 LONG ROW
我正在研究 远程调用,希望互相促进,如果还有什么问题,请 再联系,
因为很急,所以就没有好好改一下,好让你容易看懂一些,不过,依你
44名的水平,我觉得你一定会很快掌握的!
有什么问题,请提出,大家一起研究~
Function SaveOLEToBlobField(OleDDMLP:TOleContainer;
qryTemp:TQuery;sFieldName,sTempFileName,sSQl:String):Boolean;
VAR
Stream: TBlobField;
// smTemp:TMemorystream;
begin
Result := False ;
if((OleDDMLP.State=osEmpty)or(Not OleDDMLP.Modified))then
Exit ;
Stream:=TBlobField.Create(Application);
try
with qryTempdo
//保存数据
begin
Sql.Clear;
Sql.Add(sSQl);
Stream.FieldName:=sFieldName;
Stream.DataSet:=qryTemp;
RequestLive:=True;
try
Open;
EDIT;
OleDDMLP.SaveAsDocument(sTempFileName) ;
Stream.LoadFromFile(sTempFileName);
Post;
except
showmessage('对数据库操作'+Sql.text+'失败,将影响以后操作的正确性,请退出!');
exit;
end;
//End Try Except
Close;
Result := True ;
end;
finally
Stream.Free ;
end;
{ try
Stream:=TBlobField.Create(Application);//TMemorystream.Create;
smTemp:=TMemorystream.Create ;
with DM.Query1do
//保存数据
begin
Sql.Clear;
Sql.Add(Format('Select XKRTXAQCS From SJ_GZP_WH_GZPGLB Where GZPBH=''%s''',[EGZPBH.Text]));
Stream.FieldName:='XKRTXAQCS';
Stream.DataSet:=qryTemp;
RequestLive:=True;
try
Open;
EDIT;
OleDDMLP.SaveToStream(smTemp);
Stream.LoadFromStream(smTemp);
Post;
except
showmessage('对数据库操作'+Sql.text+'失败,将影响以后操作的正确性,请退出!');
exit;
end;
//End Try Except
Close;
end;
//End With
finally
Stream.Free ;
smTemp.Free ;
end;
//End Try Finanlly
}
end;
Function LoadBlobToOLE(OleDDMLP:TOleContainer;
qryTemp:TQuery;sFieldName,sTempFileName,sSQl:String):Boolean;
var
Stream: TBlobField;
// smTemp:TBlobStream;
begin
Result:= False;
Stream:=TBLOBFIELD.Create(APPLICATION);
try
with qryTempdo
begin
Close;
Sql.Clear;
Sql.Add(sSQl);
Stream.FieldName:=sFieldName;
Stream.DataSet:=qryTemp;
try
Open ;
except
end;
//Try Open
if (Stream.IsNull) then
begin
//从数据库中调票
ShowMessage('数据空');
Close ;
End else
begin
try
Stream.SaveToFile(sTempFileName);
OleDDMLP.CreateObjectFromFile(sTempFileName,False) ;
Close ;
Result:= True;
finally
end;
end;
//End if
End ;
// End With
finally
Stream.Free;
end;
{ try
Stream:=TBLOBFIELD.Create(APPLICATION);
with DM.Query1do
begin
Close;
Sql.Clear;
Sql.Add(Format('Select XKRTXAQCS From SJ_GZP_WH_GZPGLB Where GZPBH=''%s''',[EGZPBH.Text]));
Stream.FieldName:='XKRTXAQCS';
Stream.DataSet:=Dm.Query1;
try
Open ;
except
end;
//Try Open
if (Stream.IsNull) then
begin
ShowMessage('数据空');
Close ;
End else
begin
try
smTemp:=TBlobStream.Create(Stream, bmRead);
smTemp.Seek(0,sofrombegin
ning);
OleDDMLP.LoadFromStream(smTemp) ;
//OleDDMLP.
//mIsTemplet := True ;
Finally
//mIsTemplet:= False ;
smTemp.Free ;
end;
//End Try Finally
Close ;
end;
//End if
End ;
// End With
finally
Stream.Free
end;
//End Finally
}
end;