var FileName :String;FileName := ExtractFileName(OpenDialog1.FileName);with Query dobegin Close; Sql.Clear; Sql.Add('INSERT INTO MyTable VALUES FileName,:FileSource)'); ParamByName('FileName').AsString := FileName; ParamByName('FileSource').LoadFromFile(OpenDialog1.FileName,ftBolob); ExecSQL;end;
从数据库中取出文件
var FileName :String;begin with Query do begin Close; Sql.Clear; Sql.Add('SELECT * FROM MyTable WHERE FileName = '?''); Open; FileName := 'c:/'+FieldByName('FileName').AsString; (FieldByName('FileSource') AS TBlobField).SaveToFile(FileName); end;end;