如果选择文件是.txt格式的就可以存入到blob字段中,其他类型的文件保存时也不报错,原有的内容也更新了,但是内容为空。请问是什么原因?
程序如下:
procedure TForm1.Button5Click(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TMemoryStream;
bStrean :TBlobStream;
strSql : string;
strUpdateSQL : String;
strSwjgDm : string;
strZndm : string;
strDwlxDm : string;
strBbXh : String;
strBbnd : string;
begin strSwjgDm := '215000000';
strZndm := '4';
strDwlxDm := '30';
strBbXh := 'KT033.10';
strBbnd := '2006'; strUpdateSQL :='update t_dm_bb_bblx '
+' set excel_qsd = :excel_qsd, '
+' excel_file = :excel_file '
+' where swjg_dm = :swjg_dm '
+' and zn_dm = :zn_dm'
+' and dwlx_dm = :dwlx_dm'
+' and bb_xh = :bb_xh'
+' and bbnd = :bbnd';
OpenDialog1.Filter:='Excel文档(*.xls)|*.xls';{从对话窗选择文件}
if OpenDialog1.Execute then
begin
with OraQuery do
begin SQL.Clear;
SQL.Add(strUpdateSQL) ;
ParamByName('swjg_dm').AsString := strSwjgDm;
ParamByName('zn_dm').AsString := strZndm;
ParamByName('dwlx_dm').AsString := strDwlxDm;
ParamByName('bb_xh').AsString := strBbXh;
ParamByName('bbnd').AsString := strBbnd;
ParamByName('excel_qsd').AsString := 'c75';
ParamByName('excel_file').ParamType := ptInput;
ParamByName('excel_file').LoadFromFile(OpenDialog1.FileName,ftBlob);
try
Prepare;
Execute; except
showmessage('Excle表样保存失败!');
end; end; end;
end;
程序如下:
procedure TForm1.Button5Click(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TMemoryStream;
bStrean :TBlobStream;
strSql : string;
strUpdateSQL : String;
strSwjgDm : string;
strZndm : string;
strDwlxDm : string;
strBbXh : String;
strBbnd : string;
begin strSwjgDm := '215000000';
strZndm := '4';
strDwlxDm := '30';
strBbXh := 'KT033.10';
strBbnd := '2006'; strUpdateSQL :='update t_dm_bb_bblx '
+' set excel_qsd = :excel_qsd, '
+' excel_file = :excel_file '
+' where swjg_dm = :swjg_dm '
+' and zn_dm = :zn_dm'
+' and dwlx_dm = :dwlx_dm'
+' and bb_xh = :bb_xh'
+' and bbnd = :bbnd';
OpenDialog1.Filter:='Excel文档(*.xls)|*.xls';{从对话窗选择文件}
if OpenDialog1.Execute then
begin
with OraQuery do
begin SQL.Clear;
SQL.Add(strUpdateSQL) ;
ParamByName('swjg_dm').AsString := strSwjgDm;
ParamByName('zn_dm').AsString := strZndm;
ParamByName('dwlx_dm').AsString := strDwlxDm;
ParamByName('bb_xh').AsString := strBbXh;
ParamByName('bbnd').AsString := strBbnd;
ParamByName('excel_qsd').AsString := 'c75';
ParamByName('excel_file').ParamType := ptInput;
ParamByName('excel_file').LoadFromFile(OpenDialog1.FileName,ftBlob);
try
Prepare;
Execute; except
showmessage('Excle表样保存失败!');
end; end; end;
end;
原来遇到用oracle自己的ado驱动有类似问题,后改用微软的好了