Solved

Bitmap field

Posted on 1998-09-01
5
356 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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
find a node in VST 2 68
Create a path if not exists 7 77
Dynamically Created Query 3 55
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

773 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