三层结构中怎样通过ClientDataSet把word文档(里面包括文字和表格)存储到服务器端的SQL SERVER 数据库的一个字段中(100分)

  • 主题发起人 主题发起人 wwwone
  • 开始时间 开始时间
W

wwwone

Unregistered / Unconfirmed
GUEST, unregistred user!
三层结构中在客户端怎样通过ClientDataSet把word文档(里面包括文字和表格)存储到服务器端的SQL SERVER 数据库的一个字段中,怎样又通过ClientDataSet把SQL SERVER 数据库的一个字段中word的内容导出来看或导出到word文档中呢,请大家帮忙,最好能给一份源码,我全部分送上,
我qq:444094419
 
将Query改为clientdataset应该就可以了。
if FileExists('c:/temp.bmp') then
begin
TblobField(AQuery_ip101.FieldByName('image')).LoadFromFile('c:/temp.bmp');
DeleteFile('c:/temp.bmp');
end;
 
就是这样
TblobField(AQuery_ip101.FieldByName('image')).savetoFile('c:/temp.bmp');
这是保存
 
word文档中有文字和表格也一样的吗
 
以下是我的一部分代码
保存到数据库:
if ClickSign='ADD' then
begin
//olecontainer1.Enabled:=true;
GetMax();
ESMP_dm.CDS_law.Append;
ESMP_dm.CDS_law.Fieldbyname('FID').AsString:=max;
ESMP_dm.CDS_law.Fieldbyname('FNAME').AsString:=Edit2.Text;
ESMP_dm.CDS_law.Fieldbyname('FABUZHE').AsString:=Edit4.Text;
ESMP_dm.CDS_law.Fieldbyname('FSORT').AsString:=ComboBox2.Text;
ESMP_dm.CDS_law.Fieldbyname('FBDATE').AsString:=formatdatetime('yyyy-mm-dd',datetimepicker1.date);
ESMP_dm.CDS_law.Fieldbyname('SSDATE').AsString:=formatdatetime('yyyy-mm-dd',datetimepicker2.date);
Stream := TMemoryStream.Create;
try
OleContainer1.SaveToStream(Stream);
Stream.Position:=0;
tblobfield(ESMP_dm.CDS_law.Fieldbyname('ZHENGWEN')).LoadFromStream(Stream);
ESMP_dm.CDS_law.Post;
ESMP_dm.CDS_law.ApplyUpdates(0);
finally
Stream.Free;
end;
end;
用olecontainer 显示
Stream := TMemoryStream.Create;
try
TBlobField(ESMP_dm.CDS_law.FieldByName('ZHENGWEN')).SaveToStream(Stream);
if Stream.Size>0 then
begin
Stream.Position:=0;
OleContainer1.LoadFromStream(Stream);
OleContainer1.AutoActivate := aaGetFocus;
OleContainer1.SetFocus;
Button1.SetFocus;
end;
finally
Stream.Free;
end;
 
数据库中保存word的字段用blob类型
TBlodField有一个方法,loadfromfile
当然也可以用loadfromstream
 
ClientDataSet1.SaveToStream()
ClientDataSet1.LoadFromStream()
可以把数据转为流传递、完成后把流还原
 
olecontainer1 是一个控件来的吗, 网中戏,你的方法很好,可我还是不会写,可否给出一小段程序参考呢, 谢谢
 
因为我的软件内要看word的内容,因此需要olecontainer。如果你不需要看到内容,
保存到数据库:
Stream.LoadFromFile(OpenDialog1.FileName);
tblobfield(ESMP_dm.CDS_law.Fieldbyname('ZHENGWEN')).LoadFromStream(Stream);
导出:用weichao9999的方法

olecontainer是delphi自带的控件
 
oleContainer的话用huanghq123,
如果是WordApplication的话就只有用filestream,这样要稳定一些,直接用blob字段也
行,但如果文档或者图片太大的话……
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部