9 个解决方案
#1
TBlobField.LoadFromFile;
TBlobField.SaveToFile(A);
uses ShellAPI;
ShellExecute(0, 'open', PChar(A), nil, nil, SW_SHOW);
————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
TBlobField.SaveToFile(A);
uses ShellAPI;
ShellExecute(0, 'open', PChar(A), nil, nil, SW_SHOW);
————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
#2
//保存到数据库
var
ds:TAdoDataSet;
fs:TFileStream;
fn:String;
i:Integer;
id:Integer;
count:Integer;
begin
try
ds:=TAdoDataSet.Create(nil);
ds.Connection:=ADOConn;
ds.Insert;
fs:= TFileStream.Create(文件路径名,fmOpenRead);
fs.Seek(0, 0);
TBlobField(ds.FieldByName('字段名')).LoadFromStream(fs);
fs.Free;
ds.Post;
ds.Free;
except
on E:Exception do
begin
ShowMessage(E.Message);
ds.Free;
end;
end;
//打开文件,先保存为一个临时文件,再打开
fs:=TAdoBlobStream.Create(TBlobField(aqAttachFile.FieldbyName('file_entity')),bmRead);
fn:=取个名字;
fs.SaveToFile(fn);
var
ds:TAdoDataSet;
fs:TFileStream;
fn:String;
i:Integer;
id:Integer;
count:Integer;
begin
try
ds:=TAdoDataSet.Create(nil);
ds.Connection:=ADOConn;
ds.Insert;
fs:= TFileStream.Create(文件路径名,fmOpenRead);
fs.Seek(0, 0);
TBlobField(ds.FieldByName('字段名')).LoadFromStream(fs);
fs.Free;
ds.Post;
ds.Free;
except
on E:Exception do
begin
ShowMessage(E.Message);
ds.Free;
end;
end;
//打开文件,先保存为一个临时文件,再打开
fs:=TAdoBlobStream.Create(TBlobField(aqAttachFile.FieldbyName('file_entity')),bmRead);
fn:=取个名字;
fs.SaveToFile(fn);
#3
收藏
#4
想要控制WORD的话,
belllab.yeah.net有个例子
belllab.yeah.net有个例子
#5
belllab.yeah.net
这个网站打不开啊!!
这个网站打不开啊!!
#6
to austinlie(黄瓜杀手)
我想知道在数据保存到数据库中,查找的时候如何定位到你想要打开是word文件啊???
我想知道在数据保存到数据库中,查找的时候如何定位到你想要打开是word文件啊???
#7
to sophia531(雨桐)
在表中添加一字段来标记word文件(比如数字编号)即可,定位时用
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select * from <表名> where <字段1>='+<编号>);
adoquery1.sql.open;
在表中添加一字段来标记word文件(比如数字编号)即可,定位时用
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select * from <表名> where <字段1>='+<编号>);
adoquery1.sql.open;
#8
打开word文件。
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;
#9
word文件传入和传出数据库。
uses IdGlobal;
procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
var
sfilename:string;
function BlobContentTostring(const Filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
setlength(result,size);
read(pointer(result)^,size);
finally
free;
end;
end;
begin
if opendialog1.Execute then
begin
sfilename:=opendialog1.FileName;
DataModule1.ADOQuery14.Edit;
DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
DataModule1.ADOQuery14.Post;
end;
end;
procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;
uses IdGlobal;
procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
var
sfilename:string;
function BlobContentTostring(const Filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
setlength(result,size);
read(pointer(result)^,size);
finally
free;
end;
end;
begin
if opendialog1.Execute then
begin
sfilename:=opendialog1.FileName;
DataModule1.ADOQuery14.Edit;
DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
DataModule1.ADOQuery14.Post;
end;
end;
procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;
#1
TBlobField.LoadFromFile;
TBlobField.SaveToFile(A);
uses ShellAPI;
ShellExecute(0, 'open', PChar(A), nil, nil, SW_SHOW);
————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
TBlobField.SaveToFile(A);
uses ShellAPI;
ShellExecute(0, 'open', PChar(A), nil, nil, SW_SHOW);
————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
#2
//保存到数据库
var
ds:TAdoDataSet;
fs:TFileStream;
fn:String;
i:Integer;
id:Integer;
count:Integer;
begin
try
ds:=TAdoDataSet.Create(nil);
ds.Connection:=ADOConn;
ds.Insert;
fs:= TFileStream.Create(文件路径名,fmOpenRead);
fs.Seek(0, 0);
TBlobField(ds.FieldByName('字段名')).LoadFromStream(fs);
fs.Free;
ds.Post;
ds.Free;
except
on E:Exception do
begin
ShowMessage(E.Message);
ds.Free;
end;
end;
//打开文件,先保存为一个临时文件,再打开
fs:=TAdoBlobStream.Create(TBlobField(aqAttachFile.FieldbyName('file_entity')),bmRead);
fn:=取个名字;
fs.SaveToFile(fn);
var
ds:TAdoDataSet;
fs:TFileStream;
fn:String;
i:Integer;
id:Integer;
count:Integer;
begin
try
ds:=TAdoDataSet.Create(nil);
ds.Connection:=ADOConn;
ds.Insert;
fs:= TFileStream.Create(文件路径名,fmOpenRead);
fs.Seek(0, 0);
TBlobField(ds.FieldByName('字段名')).LoadFromStream(fs);
fs.Free;
ds.Post;
ds.Free;
except
on E:Exception do
begin
ShowMessage(E.Message);
ds.Free;
end;
end;
//打开文件,先保存为一个临时文件,再打开
fs:=TAdoBlobStream.Create(TBlobField(aqAttachFile.FieldbyName('file_entity')),bmRead);
fn:=取个名字;
fs.SaveToFile(fn);
#3
收藏
#4
想要控制WORD的话,
belllab.yeah.net有个例子
belllab.yeah.net有个例子
#5
belllab.yeah.net
这个网站打不开啊!!
这个网站打不开啊!!
#6
to austinlie(黄瓜杀手)
我想知道在数据保存到数据库中,查找的时候如何定位到你想要打开是word文件啊???
我想知道在数据保存到数据库中,查找的时候如何定位到你想要打开是word文件啊???
#7
to sophia531(雨桐)
在表中添加一字段来标记word文件(比如数字编号)即可,定位时用
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select * from <表名> where <字段1>='+<编号>);
adoquery1.sql.open;
在表中添加一字段来标记word文件(比如数字编号)即可,定位时用
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select * from <表名> where <字段1>='+<编号>);
adoquery1.sql.open;
#8
打开word文件。
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;
#9
word文件传入和传出数据库。
uses IdGlobal;
procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
var
sfilename:string;
function BlobContentTostring(const Filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
setlength(result,size);
read(pointer(result)^,size);
finally
free;
end;
end;
begin
if opendialog1.Execute then
begin
sfilename:=opendialog1.FileName;
DataModule1.ADOQuery14.Edit;
DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
DataModule1.ADOQuery14.Post;
end;
end;
procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;
uses IdGlobal;
procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
var
sfilename:string;
function BlobContentTostring(const Filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
setlength(result,size);
read(pointer(result)^,size);
finally
free;
end;
end;
begin
if opendialog1.Execute then
begin
sfilename:=opendialog1.FileName;
DataModule1.ADOQuery14.Edit;
DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
DataModule1.ADOQuery14.Post;
end;
end;
procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;