Solved

Bitmap field

Posted on 1998-09-01
5
360 Views
Last Modified: 2013-12-03
How can I insert a bitmap in a TImage component to a SQL
Server 6.5 database image field using TQuery.

Please send me a piece of code

thanks in advance
0
Comment
Question by:Cumhur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1338340
Something like its

SQL: insert into Images(Image) values(:image)

Code:
procedure TForm1.Button1Click(Sender: TObject);
var Stream: TStream;
begin
  Stream := TMemoryStream.Create;
  try
    Image1.Picture.Bitmap.SaveToStream(Stream);
    Stream.Position := 0;
    Query1.ParamByName('Image').LoadFromStream(Stream, ftBlob);
  finally
    Stream.Free;
  end;
  Query1.ExecSQL;
end;

0
 

Author Comment

by:Cumhur
ID: 1338341
Finally I did it.... Thanx for your help. I was going mad, because i've been struggling with stream, memorystream,loadfromstream,...etc. for two days.
I was giving parameter as query1.params[0].AsBlob:= stream
That was my problem. i couldn't think of giving parameter in that way, ( two days...:))
when i gave parameter as above, it gave errors of incompatible types string and tstream. I typecasted it as string(stream)....whatever... Thanx for help.... Valla, if i had 200 points, i would give all for this answer (as i said 2 days...)...
0
 

Author Comment

by:Cumhur
ID: 1338342
Finally I did it.... Thanx for your help. I was going mad, because i've been struggling with stream, memorystream,loadfromstream,...etc. for two days.
I was giving parameter as query1.params[0].AsBlob:= stream
That was my problem. i couldn't think of giving parameter in that way, ( two days...:))
when i gave parameter as above, it gave errors of incompatible types string and tstream. I typecasted it as string(stream)....whatever... Thanx for help.... Valla, if i had 200 points, i would give all for this answer (as i said 2 days...)... But why did you add answer as a comment? Answer then let me give you 10 points (which all i have)
0
 
LVL 3

Accepted Solution

by:
vladika earned 10 total points
ID: 1338343
Ok. This is my "official" answer
0
 

Author Comment

by:Cumhur
ID: 1338344
And the points goes to...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question