程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> TClientDataSet[20]: 使用 Blob 字段

TClientDataSet[20]: 使用 Blob 字段

編輯:Delphi

 Blob(Binary Large Object) 字段包括:

ftBlob, 
ftMemo, 
ftGraphic, 
ftFmtMemo, 
FTParadoxOle, 
ftDBaSEOle, 
ftTypedBinary, 
ftCursor, 
ftFixedChar, 
ftWideString, 
ftLargeint, 
ftADT, 
ftArray, 
ftReference, 
ftDataSet, 
ftOraBlob, 
ftOraClob, 
ftVariant, 
ftInterface, 
ftIDispatch, 
ftGuid, 
ftTimeStamp, 
ftFMTBcd, 
ftFixedWideChar, 
ftWideMemo 
 
{ TBlobType = ftBlob..ftWideMemo }  

  示例:

TClientDataSet[20]: 使用 Blob 字段

uses IOUtils, MMSystem; 
 
{ 建立包含 Blob 字段的數據集, 並載入 Windows\Media\*.wav } 
procedure TForm1.FormCreate(Sender: TObject); 
var 
 MediaPath, Path: string; 
begin 
 with ClIEntDataSet1 do begin 
  FIEldDefs.Add('WavFileName', ftString, 32); 
  FIEldDefs.Add('WAV', ftBlob); 
  CreateDataSet; 
 end; 
 
 MediaPath := GetEnvironmentVariable('SystemRoot') + '\Media\'; 
 for Path in TDirectory.GetFiles(MediaPath, '*.wav') do 
 begin 
  ClIEntDataSet1.Append; 
  ClIEntDataSet1['WavFileName'] := ExtractFileName(Path); 
  TBlobField(ClientDataSet1.FIEldByName('WAV')).LoadFromFile(Path); 
 end; 
 ClIEntDataSet1.MergeChangeLog; 
end; 
 
{ 播放 } 
procedure TForm1.Button1Click(Sender: TObject); 
var 
 BlobStream: TClIEntBlobStream; 
 BlobField: TBlobFIEld; 
begin 
 BlobField := ClientDataSet1.FieldByName('WAV') as TBlobFIEld; 
 BlobStream := TClientBlobStream.Create(BlobFIEld, bmRead); 
 Win32Check(PlaySound(BlobStream.Memory, 0, SND_SYNC or SND_MEMORY)); 
 BlobStream.Free; 
end; 


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved