»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
¼¼ÊõÎĵµ > Delphi
DELPHI´æÈ¡JPEGÎļþµ½SQL ServerÊý¾Ý¿â(ÐøÎÄ)
·¢±íÈÕÆÚ£º2003-07-23 00:00:00×÷Õߣº¸ ³ö´¦£º  

¡¡¡¡ÔÚ"DELPHI´æÈ¡JPEGÎļþµ½SQL ServerÊý¾Ý¿â"·¢±íÖ®ºó£¬ÓÐÐí¶àÍøÓÑÀ´µç±íʾ֧³ÖºÍÏà¹ØµÄ¼¼Êõ×Éѯ£¬ÔÚ´ËÊ×ÏȶÔÄÇЩ¹ØÐı¾ÎĵÄÅóÓÑÃDZíʾÖÔÐĵĸÐл¡£

¡¡¡¡ÓÉÓÚÍøÓѵÄÐèÒª×öÒ»¸öµµ°¸¹ÜÀíϵͳ£¬´æÈ¡jpegÎļþµ½sql 2000Êý¾Ý¿âÖУ¬µ«ÔÚdbimageÖм°qrdbimageÖоù²»ÄÜÕý³£ÏÔʾjpegµÄÎļþ£¬´ËΪborlandµÄÏÞÖÆ£¬ËäȻʹÓõÚÈý·½¿Ø¼þÄÜ´ïµ½ÒªÇ󣬵«ÎÒÃÇ»¹ÊÇÀ´Ô­Ê¼µÄʵÏÖÒ»ÏÂÕâ·½ÃæµÄ¼¼Êõ£¬ÆäʵԭÀíÊ®·Ö¼òµ¥£¬¼ÈÈ»ÎÒÃÇÔÚ"DELPHI´æÈ¡JPEGÎļþµ½SQL ServerÊý¾Ý¿â"ÄÜ´æ´¢jpegÎļþ£¬Ò²ÄÜÔÚimageÖÐÏÔʾ£¬µ«Ò»½Ó´¥dbÀàµÄͼÏóÏÔʾ¿Ø¼þ¾ÍÐв»Í¨ÁË£¬ÎÒÃÇ¿ÉÒÔÔÚjpegÎļþ´æÈëÊý¾Ý¿â֮ǰת»»³ÉbmpÎļþÔÙ´æÈëÊý¾Ý¿â¼´¿É£¬³ÌÐòÔËÐл·¾³delphi5+ado+sql 2000×ÀÃæ°æ+win98se2×îÖհ棬Êý¾Ý¿âÖдæ·ÅͼƬ×ֶεÄÀàÐÍΪimage£¬³ÌÐòÔ´´úÂëÈçÏ£º

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

Db, DBCtrls, Grids, DBGrids, ADODB, ExtDlgs,jpeg, ExtCtrls, StdCtrls;

type

TForm1 = class(TForm)

ADOConnection1: TADOConnection;

ADOQuery1: TADOQuery;

DataSource1: TDataSource;

DBGrid1: TDBGrid;

DBImage1: TDBImage;

ADOQuery1ID: TStringField;

ADOQuery1FIELD: TStringField;

ADOQuery1STYLE: TStringField;

ADOQuery1SYSTEM: TStringField;

ADOQuery1DATE: TDateTimeField;

ADOQuery1PERSON1: TStringField;

ADOQuery1PERSON2: TStringField;

ADOQuery1PERSON3: TStringField;

ADOQuery1PHOTO: TBlobField;

ADOQuery1DESCRIPTION: TStringField;

OpenPictureDialog1: TOpenPictureDialog;

Image1: TImage;

Button1: TButton;

Memo1: TMemo;

procedure DBImage1Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormShow(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.DBImage1Click(Sender: TObject);

var

picstream:tadoblobstream;

bmppic:tbitmap;

jpgpic:tjpegimage;

bmpstream:TMemoryStream;

begin

if form1.OpenPictureDialog1.Execute then

begin

if extractfileext(form1.openpicturedialog1.filename)='.bmp' then

begin

adoquery1.edit;

picstream:=tadoblobstream.Create(tblobfield(ADOQuery1PHOTO),bmWrite);

//×¢£ºÉϾä´úÂëÖеÄADOQuery1PHOTOÊÇadoquery1ÖеĹ̶¨×Ö¶ÎphotoµÄ¹Ì¶¨×ֶεÄname

//Óû§ÐèÒªÊÖ¹¤Ìí¼Ó¹Ì¶¨×ֶΣ¬Ò²¿ÉÓÃfields[i]À´½øÐÐÑ¡Ôñ£¬ÕâµãÔÚ

//"DELPHI´æÈ¡JPEGÎļþµ½SQL ServerÊý¾Ý¿â"ÕâƪÎÄÕÂÖÐûÓÐ×¢ÊÍ£¬ÖÁʹÐí¶àÅóÓÑûÓÐ

//±àÒë³É¹¦¡£

picstream.LoadFromFile(openpicturedialog1.filename);

picstream.Position:=0;

adoquery1.edit;

tblobfield(ADOQuery1PHOTO).loadfromstream(picstream);

adoquery1.post;

adoquery1.edit;

picstream.free;

end

else

begin

jpgpic:=tjpegimage.Create;

bmppic:=tbitmap.Create;

bmpstream:=tmemorystream.Create;

jpgpic.LoadFromFile(openpicturedialog1.filename);

bmppic.Assign(jpgpic);

bmppic.SaveToStream(bmpstream);

adoquery1.edit;

picstream:=tadoblobstream.Create(tblobfield(ADOQuery1PHOTO),bmWrite);

//×¢£ºÉϾä´úÂëÖеÄADOQuery1PHOTOÊÇadoquery1ÖеĹ̶¨×Ö¶ÎphotoµÄ¹Ì¶¨×ֶεÄname

//Óû§ÐèÒªÊÖ¹¤Ìí¼Ó¹Ì¶¨×ֶΣ¬Ò²¿ÉÓÃfields[i]À´½øÐÐÑ¡Ôñ£¬ÕâµãÔÚ

//"DELPHI´æÈ¡JPEGÎļþµ½SQL ServerÊý¾Ý¿â"ÕâƪÎÄÕÂÖÐûÓÐ×¢ÊÍ£¬ÖÁʹÐí¶àÅóÓÑûÓÐ

//±àÒë³É¹¦¡£

picstream.LoadFromStream(bmpstream);

picstream.Position:=0;

adoquery1.edit;

tblobfield(ADOQuery1PHOTO).loadfromstream(picstream);

adoquery1.post;

jpgpic.free;

bmppic.free;

bmpstream.free;

adoquery1.edit;

picstream.free;

end;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

memo1.Lines.Add(form1.openpicturedialog1.filter);

end;

procedure TForm1.FormShow(Sender: TObject);

begin

form1.openpicturedialog1.filter:='All *.jpg;*.jpeg;*.bmp;|*.jpg;*.jpeg;*.bmp;)';

end;

end.

ÖÁ´ËʵÏֵŦÄÜ´úÂëÈçÉÏËùÀý£¬Ï£ÍûÄܶÔÐèÒªÕâ·½Ãæ×ÊÁϵÄÅóÓÑÓÐËù°ïÖú.ÎÒµÄÁªÏµ·½Ê½Îª£ºEmail:delphijl@163.com

¸öÈËÖ÷Ò³:http://delphijl.99898.com(¼ªÁÖdelphi¿ª·¢Íø)

QQ:123168091(¼¼Êõ½»Á÷£¬²»ÁÄÌì!)¡£

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.0042