請教,如何將image顯示的圖相儲存到資料庫中?

來源:互聯網
上載者:User
請教,如何將image顯示的圖相儲存到資料庫中? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061113160341154.html
請教,如何將image顯示的圖相儲存到資料庫中?   多謝了!!!!!!!!

看下常式  
  http://www.delphibox.com/article.asp?articleid=3685

以流的方式儲存一下。我做過,就按照這樣的。

var  
      _picture:   TFileStream;  
  begin  
            _picture:=   TFileStream.Create('c:\11.bmp',fmOpenRead);  
            with   ADOCommand   do  
            begin  
                    Parameters.Clear;  
                    Parameters.AddParameter.Name:='UserPicture';//添加一個參數    
                    Parameters.AddParameter.DataType:=   ftBlob;//參數類型為資料流  
                    if   _picture<>nil   then  
                          Parameters.ParamByName('UserPicture').LoadFromStream(_picture,ftBlob);//給參數賦值  
  //下面是你的insert   sql語句  
  //image類型欄位在values裡對應':userpicture'參數  
                            fsql:=   'insert   into   UserInfo   (UserID,USERNAME,LOGNNAME,'  
                                        +'UsePsw,UserSex,UserBirthday,LearnLevel,UserDutyName,UserDuty,UserSecOffice,'  
                                        +'SuitSpecID,DeptID,ClassID,UserAddr,UserPhone,UserPicture,UserPictureEx,UserPower,Remark)   '  
                                        +'values   ('+inttostr(fid)+','''  
                                        +trim(editName.Text)+''','''+trim(editLogn.Text)+''','''+trim(editPswd1.Text)+''','''  
                                        +cboxUserSex.Text+''',cdate('''+DateTimeToStr(UserBirthday.DateTime)+'''),'''  
                                        +cboxXl.Text+''','''+trim(editZc.Text)+''','''+trim(editZw.Text)+''','''  
                                        +trim(editKs.Text)+''','+inttostr(_SuitSpecID)+','+inttostr(_DeptID)+','''  
                                        +strTemp2+''','''+trim(editAddr.Text)+''','''+trim(editPhone.Text)+''',:userpicture,'''  
                                        +_picEx+''','+inttostr(_power)+','''+memo1.Text+''')';  
                            CommandText:=   fsql;  
                            try  
                                    Execute;  
                                    if   messagebox(Handle,pchar('添加使用者成功!'+#13+#13+'是否繼續添加?'),  
                                          pchar('提示'),mb_yesno+MB_ICONQUESTION)=mryes   then  
                                    begin  
   
                                    end   else   Close;  
                            except  
                            end;  
                    end;  
  end;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.