Solved

Bitmap field

Posted on 1998-09-01
5
354 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ok. This is my "official" answer
0
 

Author Comment

by:Cumhur
Comment Utility
And the points goes to...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

9 Experts available now in Live!

Get 1:1 Help Now