BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Save JPG format in SQL 2K

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Missagh
Guest





PostPosted: Tue Jul 27, 2004 2:32 pm    Post subject: Save JPG format in SQL 2K Reply with quote



Hi, I Want To save a JPG file format intor SQL 2K DB, but it seams that SQL
can only support bitmap formats, do you have any suggestion or guideline?!


Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Tue Jul 27, 2004 3:00 pm    Post subject: Re: Save JPG format in SQL 2K Reply with quote



Missagh wrote:

Quote:
Hi, I Want To save a JPG file format intor SQL 2K DB, but it seams
that SQL can only support bitmap formats, do you have any suggestion
or guideline?!

*TDBImage* has this limitation. SQL Server, I'm reasonably sure, does
not.

OTOH, the (non-DB) TImage can support JPEGs if you add JPEG to the
uses clause of the form containing it.

-Craig

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
How to ask questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html

Back to top
Paul Q
Guest





PostPosted: Wed Jul 28, 2004 2:56 am    Post subject: Re: Save JPG format in SQL 2K Reply with quote



Interesting.. What routine do you use to stuff it into that field?


"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote


Quote:
You can store any binary data in a blob field
TdbImage only supports bitmap images. If you want to display a jpeg from
and

----------



Back to top
Missagh
Guest





PostPosted: Wed Jul 28, 2004 9:48 am    Post subject: Re: Save JPG format in SQL 2K Reply with quote

Dear Brian
Thank you for your guidline and sample code but as I Said I Don't know
How to save JPG or JPEG format into SQL 2K server!
The only format that SQL can support and save it into Image field type is
BMP one, so I have to just save BMP format or convert other formates into
bmp and then try to save them, and as you know I have to save large amount
of data instead of it's JPG format or any other better formats...
do you have any suggestion about saving them into sql 2k?!

Thank you for your attention :)

"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote

Quote:

Hi, I Want To save a JPG file format intor SQL 2K DB, but it seams that
SQL
can only support bitmap formats, do you have any suggestion or
guideline?!

You can store any binary data in a blob field
TdbImage only supports bitmap images. If you want to display a jpeg from
and
SQL database you will need to use a Timage and load it with code.
here is some sample code to load A timage in the AfterScroll event
procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
var
MS: TMemoryStream;
J1: TJPEGImage;
begin
J1 := TJPEGImage.Create;
MS := TMemoryStream.Create;
try
TBlobField(DataSet.Fieldbyname('myBlob')).SaveToStream(MS);
MS.Seek(0,soFromBeginning);
with J1 do begin
PixelFormat := jf24Bit;
Scale := jsFullSize;
Grayscale := False;
Performance := jpBestQuality;
ProgressiveDisplay := True;
ProgressiveEncoding := True;
LoadFromStream(MS);
end;
if MS.Size >0 then
Image1.Picture.Assign(J1)
else
Image1.Picture.Assign(nil);

finally
J1.Free;
MS.Free;
end;
end;

--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]



Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Wed Jul 28, 2004 12:40 pm    Post subject: Re: Save JPG format in SQL 2K Reply with quote

Paul Q wrote:

Quote:
What routine do you use to stuff it into that field?

Essentially the opposite of the one he posted. Save from the TImage
or TJPEGImage* to the BlobField instead of vice/versa, along with the
usual calls to Edit/Post.

* TImage is a GUI control which displays an image. TJPEGImage is a
non-GUI control which knows how to read JPEG data. You can use
TJPEGImage if you don't need a GUI display, or TImage (adding JPEG to
the uses clause of the containing form) if you do need a display.
Either one works.

-Craig

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Everything You Need to Know About InterBase Character Sets:
http://blogs.teamb.com/craigstuntz/articles/403.aspx

Back to top
Martijn Tonies
Guest





PostPosted: Wed Jul 28, 2004 4:23 pm    Post subject: Re: Save JPG format in SQL 2K Reply with quote


Quote:
Don't use an Image field on SQL Server, use a BLOB field instead. As Brian
said, you can store any binary object on a BLOB (binary) field.
best regards

IMAGE is the BLOB datatype in MS SQL Server.


--
With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com



Back to top
Missagh
Guest





PostPosted: Tue Aug 03, 2004 3:03 am    Post subject: Re: Save JPG format in SQL 2K Reply with quote

It Works Perfectly ;)

"TIA"

"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote

Quote:

Thank you for your guidline and sample code but as I Said I Don't know
How to save JPG or JPEG format into SQL 2K server!
TblobField has loadFromfile and LoadFromStream methods
Tparameter also has these methods. You will employ one of them depending
on if
you post directly to the database or use SQL Insert code
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.