2013-08-15
展开全部
var
tf:tfilestream;
name,path:string;
p:integer;
begin
p:=0;
if form1.OpenDialog1.Execute then
begin
try
name:=form1.OpenDialog1.FileName;
form1.OpenDialog1.GetNamePath;
showmessage(name);
tf:=tfilestream.Create(name,fmOpenRead);
adoquery1.Edit;
adoquery1.Insert;
tblobfield(adoquery1.FieldByName('contect')).loadfromstream(tf);//contect为表中存储文件内容的字段名
p:=pos('.',name);
name:=copy(name,p,length(name)-p+1);
adoquery1.FieldByName('name').Value:=name;//name为表中存储文件后缀名的字段
adoquery1.Post;
tf.Free;
except
tf.Free;
end;
end;
tf:tfilestream;
name,path:string;
p:integer;
begin
p:=0;
if form1.OpenDialog1.Execute then
begin
try
name:=form1.OpenDialog1.FileName;
form1.OpenDialog1.GetNamePath;
showmessage(name);
tf:=tfilestream.Create(name,fmOpenRead);
adoquery1.Edit;
adoquery1.Insert;
tblobfield(adoquery1.FieldByName('contect')).loadfromstream(tf);//contect为表中存储文件内容的字段名
p:=pos('.',name);
name:=copy(name,p,length(name)-p+1);
adoquery1.FieldByName('name').Value:=name;//name为表中存储文件后缀名的字段
adoquery1.Post;
tf.Free;
except
tf.Free;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询