Solved

Bitmap field

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now