Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

i 'll be mad with jpg

i want to save jpg to the blob field of SQL Server(BDE connection)

but it always tell me bitmap image is invalid,why,why???

here is my code:

var
FileStream : TFileStream;
BlobStream : TBlobStream;

begin

if OpenPictureDialog1.Execute then
  with Table1 do
begin

  FileStream := TFileStream.Create(OpenPictureDialog1.FileName, fmOpenRead);
  Edit;
  BlobStream := TBlobStream(CreateBlobStream(FieldByName('ThumbImage'), bmWrite));
  BlobStream.Seek(0,soFromBeginning);
  BlobStream.Truncate;
  BlobStream.CopyFrom(FileStream,FileStream.Size);
  FileStream.Free;
  BlobStream.Free;
  Post;
 
end;
0
ws1999
Asked:
ws1999
  • 4
  • 2
  • 2
  • +4
1 Solution
 
kretzschmarCommented:
? don't use a dbimage or a graphic-blob type
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  Did you include the Jpeg unit in the uses clause?
0
 
ws1999Author Commented:
ofcourse otherwise it cannot pass the compiler
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
cubudCommented:
Why don't you just do

TBlobField(Table1.FieldByName('Something')).LoadFromFile(filename);

Pete
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Open source)
0
 
kretzschmarCommented:
hi, a bit correction in your code
(of course cubud is right, you can easy use this suggestion,
even if i think that a comment would be better than an answer)

FileStream := TFileStream.Create(OpenPictureDialog1.FileName, fmOpenRead);
Edit;
BlobStream := TBlobStream(CreateBlobStream(FieldByName('ThumbImage'), bmWrite));
filestream.position := 0;  //<-add this line -> spool back the stream
BlobStream.CopyFrom(FileStream,0); // change this
FileStream.Free;
BlobStream.Free;
Post;
                     
meikl ;-)
0
 
cubudCommented:
But why mess around creating all that code when typecasting as a TBlobField and using LoadFromFile does it all for you ?


Pete
http://www.HowToDoThings.com (Articles)
http://www.StuckIndoors.com/delphi (Open-source)
0
 
AvonWyssCommented:
cubud, because your typecasting could lead to problems if
* the field was not a blob field
* some other part of the program (maybe some DB explorer or anything) expects the data to be in a certain format

Typecasts should be used with extreme caution, and I believe that you example does not do this.

Also, please read http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
0
 
cubudCommented:
Reading that URL you provided I see no point whatsoever in having an "Answer" option.  It holds up the process needlessly and provides no benefit at all.  Maybe it should be removed ?

0
 
AvonWyssCommented:
cubud, over the last years there have been lots of discussions because of this "answer" option. Actually, many experts are not very happy with it. A better option may have been to allow multiple experts to answer (e.g. remove the locking aspect) or to rename it to "lock question for evaluation" or so. I use it sometimes when a question is solved (in means of feedback by the questioner) but not yet graded.

Most, if not all, newcomer experts are cought by this "trap". So when I encounter this situation, I try to make the expert aware of this pitfall. Once again, welcome to EE and have a good time!
0
 
cubudCommented:
Exactly, my opinion of "the answer" will undoubtedly be different to someone else's.  The LOCK option should really be for administrators and the question poster.

0
 
amp072397Commented:
ws1999:

You have many open questions to which you must return:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20264790
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20256743
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20250343
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20249986
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20187323
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20184015
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20181707
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20180448
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20169990
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=11401958
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20230693
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20194172
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187856
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187852
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187466
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182301
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182182
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181487
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181301
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180787
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180436
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20172201
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20153303

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/8
0
 
MoondancerCommented:
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY REGARDING YOUR ACCOUNT AND OPEN QUESTIONS.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11401958.html
http://www.experts-exchange.com/questions/Q.20169990.html
http://www.experts-exchange.com/questions/Q.20180448.html
http://www.experts-exchange.com/questions/Q.20181301.html
http://www.experts-exchange.com/questions/Q.20182182.html
http://www.experts-exchange.com/questions/Q.20184015.html
http://www.experts-exchange.com/questions/Q.20249986.html
http://www.experts-exchange.com/questions/Q.20264790.html
http://www.experts-exchange.com/questions/Q.20180436.html
http://www.experts-exchange.com/questions/Q.20187323.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20181707.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
MoondancerCommented:
Finalized.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now