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

請較一個convert的問題

答題得分者是:hagar
hslin
一般會員


發表:7
回覆:5
積分:2
註冊:2003-10-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-20 13:46:38 IP:61.229.xxx.xxx 未訂閱
我使用ACCESS為資料庫 希望用adoquery將memo的欄位型態內容顯示在dbgrid 搜尋前面幾位前輩的文章好像可以用convert函數 寫法如下 select Convert(varchar(255), note)as note1 from consumer 其中note欄位型態為MEMO,note1是我新增欄位要顯示轉換結果的 可是程式回應convert函數未定義
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-20 14:05:50 IP:202.39.xxx.xxx 未訂閱
Showing Memo Fields in a DbGrid: http://www.q3.nu/trucomania/truco.cgi?354&ing
 procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
   Field: TField; State: TGridDrawState);
 var
   Grid         : TStringGrid;
   Texto   : String;
   Rectangulo   : TRect;
 begin
   Rectangulo:=Rect;
   Grid := TStringGrid(Sender);
   if Field.IsBlob then
   begin
     Grid.Canvas.FillRect(Rect);
     Texto := Field.AsString;
     DrawText( Grid.Canvas.Handle,
               PChar(Texto),
               StrLen(PChar(Texto)),
               Rectangulo,
               DT_WORDBREAK);
   end;
 end;
How to display memo fields in a TDBGrid: http://www.lmc-mediaagentur.de/dpool/tips/0454.htm
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
var
  P: array [0..50] of char;  {array size is number of characters needed}
  BS: tBlobStream;  {from the memo field}
  S: String;
begin
  if Field is TMemoField then
  begin
    with (Sender as TDBGrid).Canvas do
    begin
      BS:= tBlobStream.Create(TBlobField(Field), bmRead);
      FillChar(P, SizeOf(P), #0);  {terminate the null string}
      BS.Read(P, 50);  {read 50 chars from memo into blobStream}
      BS.Free;
      S:= StrPas(P);
      while Pos(#13, S) > 0 do
        S[Pos(#13, S)] := ' ';
      while Pos(#10, S) > 0 do
        S[Pos(#10, S)] := ' ';
      FillRect(Rect);  {clear the cell}
      TextOut(Rect.Left, Rect.Top, S);  {fill cell with memo data}
    end;
  end;
end;
--- Everything I say is a lie.
hslin
一般會員


發表:7
回覆:5
積分:2
註冊:2003-10-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-20 17:37:39 IP:61.229.xxx.xxx 未訂閱
真的不好意思 因為我是新手 這兩個PROCEDURE要如何用啊????
leo2568
中階會員


發表:54
回覆:124
積分:70
註冊:2003-09-21

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-12-20 17:57:21 IP:61.217.xxx.xxx 未訂閱
引言: 真的不好意思 因為我是新手 這兩個PROCEDURE要如何用啊????
╭╧╮╭╧╮╭╧╮╭╧╮╭╮│║│║│║ ╘∞╛╘∞╛╘∞╛╘∞╛ . ﹒﹒‧∴ ☆.....
hslin
一般會員


發表:7
回覆:5
積分:2
註冊:2003-10-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-12-20 19:08:49 IP:61.229.xxx.xxx 未訂閱
thanks
系統時間:2024-06-24 3:32:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!