全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1302
推到 Plurk!
推到 Facebook!

function GetBlobFieldData

尚未結案
LPH
一般會員


發表:53
回覆:43
積分:19
註冊:2003-04-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-28 17:48:11 IP:218.162.xxx.xxx 未訂閱
function GetBlobFieldData(FieldNo: Integer; var Buffer: TBlobByteData): Integer; override; 要怎麼用.....
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-29 08:17:56 IP:218.166.xxx.xxx 未訂閱
這個function 好像真的滿少資料 而且我也不知道您是那一個元件的GetBlobFieldData 參考看看吧 TDataSet::GetBlobFieldData GetBlobFieldData reads blob data from the field specified by FieldNo into a Buffer. The buffer is a dynamic array of bytes, so that it can grow to accommodate the size of the BLOB data. GetBlobFieldData returns the size of the buffer. TCustomADODataSet::GetBlobFieldData Most applications do not need to call GetBlobFieldData, this method being used internally by descendants of TCustomADODataSet. GetBlobFieldData reads blob data from the field specified by FieldNo into a Buffer. The buffer is a dynamic array of bytes, so that it can grow to accommodate the size of the BLOB data. GetBlobFieldData returns the size of the buffer. TBDEDataSet::GetBlobFieldData GetBlobFieldData reads blob data from the field specified by FieldNo into a Buffer. The buffer is a dynamic array of bytes, so that it can grow to accommodate the size of the BLOB data. GetBlobFieldData returns the size of the buffer.
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-30 14:43:20 IP:218.1.xxx.xxx 未訂閱
很简单呀,你定义一个TBlobByteData类型的变量就行了,如
var
  AData:TBlobByteData;
begin
  ADOQuery1.Open;
  ADOQuery1.GetBlobFieldData(2,AData);
你看看delphi的DB.pas的原码:
function TDataSet.GetBlobFieldData(FieldNo: Integer; var Buffer: TBlobByteData): Integer;
var
  Stream: TStream;
begin
  Stream := CreateBlobStream(FieldByNumber(FieldNo) as TBlobField, bmRead);
  try
    Result := Stream.Size;
    if Result > 0 then
    begin
      if Length(Buffer) <= Result then
        SetLength(Buffer, Result   Result div 4);
      Stream.Read(Buffer[0], Result);
    end;
  finally
    Stream.Free;
  end;
end;
它自己跟你分配AData的大小,不用考虑够不够。剩下的问题是看你如何使用AData,你也可以这样获得blob的资料:
var
  MS:TMemoryStream;
begin
  ADOQuery1.Open;
  MS:=TMemoryStream.Create;
  TBlobField(ADOQuery1.Fields[2]).SaveToStream(MS);
------
江上何人初见月,江月何年初照人
系統時間:2024-05-18 13:41:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!