用image控件不能正常显示Sql server2000数据库中的图片
生活随笔
收集整理的這篇文章主要介紹了
用image控件不能正常显示Sql server2000数据库中的图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用image控件不能正常顯示Sql server2000數據庫中的圖片 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_2006120308470195.html
大家好: ?
? ? ? ? 我想用image控件顯示Sql ? server2000數據庫中的圖片,程序如下。但出現錯誤,請指點。 ?
? ?
? procedure ? TForm1.Button4Click(Sender: ? TObject); ?
? var ?
? ? ? tmpstream ? : ? tmemorystream; ?
? begin ?
? adoquery2.Close; ?
? adoquery2.SQL.Clear ? ; ?
? adoquery2.SQL.Text:='select ? * ? from ? mao ? '; ?
? adoquery2.Prepared ? :=true; ?
? adoquery2.Open ? ; ?
? tmpstream:=tmemorystream.Create; ?
? try ?
? ? ? tblobfield(adoquery2.Fieldbyname('tuxiang')).SaveToStream(tmpstream); ?
? ? ? tmpstream.Position:=0; ? ? ? //少了它不行。 ?
? ? ? image1.Picture.Graphic.LoadFromStream(tmpstream); ? //顯示access ? violation ?
? finally ?
? ? ? tmpstream.Free; ?
? end; ?
? end; ?
? ?
? 當程序執行到 ? image1.Picture.Graphic.LoadFromStream(tmpstream) ? 這 ?
? 一句時系統報錯,顯示錯誤信息Access ? Violation。為什么會出現這種情況,請老師指點。 ?
? ?
? 最后問一句,tmpstream.position:=0這一句為什么不能少?
http://www.delphi2007.net/DelphiMultimedia/html/delphi_2006120308470195.html
大家好: ?
? ? ? ? 我想用image控件顯示Sql ? server2000數據庫中的圖片,程序如下。但出現錯誤,請指點。 ?
? ?
? procedure ? TForm1.Button4Click(Sender: ? TObject); ?
? var ?
? ? ? tmpstream ? : ? tmemorystream; ?
? begin ?
? adoquery2.Close; ?
? adoquery2.SQL.Clear ? ; ?
? adoquery2.SQL.Text:='select ? * ? from ? mao ? '; ?
? adoquery2.Prepared ? :=true; ?
? adoquery2.Open ? ; ?
? tmpstream:=tmemorystream.Create; ?
? try ?
? ? ? tblobfield(adoquery2.Fieldbyname('tuxiang')).SaveToStream(tmpstream); ?
? ? ? tmpstream.Position:=0; ? ? ? //少了它不行。 ?
? ? ? image1.Picture.Graphic.LoadFromStream(tmpstream); ? //顯示access ? violation ?
? finally ?
? ? ? tmpstream.Free; ?
? end; ?
? end; ?
? ?
? 當程序執行到 ? image1.Picture.Graphic.LoadFromStream(tmpstream) ? 這 ?
? 一句時系統報錯,顯示錯誤信息Access ? Violation。為什么會出現這種情況,請老師指點。 ?
? ?
? 最后問一句,tmpstream.position:=0這一句為什么不能少?
可能是圖像格式問題,Timage不能識別, ?
? ?
? tmpstream.position:=0不過是將流的位置移到最開始,保存到流時流指針已經移到流的尾部,所以要移到開始位置,好Load ?
?
應該是圖片格式,image不支持
總結
以上是生活随笔為你收集整理的用image控件不能正常显示Sql server2000数据库中的图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 挂马新手段
- 下一篇: ***必须要掌握的计算机知识