AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi TStringStream to BlobStream
Thema durchsuchen
Ansicht
Themen-Optionen

TStringStream to BlobStream

Ein Thema von mr_fahrrad · begonnen am 9. Jan 2007 · letzter Beitrag vom 9. Jan 2007
Antwort Antwort
mr_fahrrad

Registriert seit: 28. Dez 2006
46 Beiträge
 
#1

TStringStream to BlobStream

  Alt 9. Jan 2007, 18:02
Datenbank: SqlExpress • Zugriff über: aDO
Hi

I have a problem when I try use the copyFrom to copy a BlobStream from a StringStream



Delphi-Quellcode:
procedure TfrmHelpEdt.sButton2Click(Sender: TObject);
var
blob:TStream;
StringStream : TStream;
begin

  with ADOTbl_HTDATA do //is a AdoTable
    begin
      Active:=true;
      Insert;
       blob:=CreateBlobStream(FieldByName('HD_source'), bmWrite);
       StringStream:=TStringStream.Create(getHtml); //getHTML function Return a string
       blob.Position:=0;
       blob.Seek(0, soFromBeginning);
       blob.CopyFrom(StringStream, StringStream.size);
      Post;
      Active:=false;
    end;
The field HD_Source not allow null and the error say "cannot insert null value in hd_source"...
so, I belive that error is in the line blob.CopyFrom(StringStream, StringStream.size);

Can anyone help me?
  Mit Zitat antworten Zitat
Der_Unwissende

Registriert seit: 13. Dez 2003
Ort: Berlin
1.756 Beiträge
 
#2

Re: TStringStream to BlobStream

  Alt 9. Jan 2007, 19:14
Hi,
these lines look a little redundant

Zitat von mr_fahrrad:
Delphi-Quellcode:
  blob.Position:=0;
  blob.Seek(0, soFromBeginning);
The both of them should do the same, but

Zitat von mr_fahrrad:
Delphi-Quellcode:
  blob.Position:=0;
  StringStream.Position := 0;
should do better (untested, I might be wrong)

Regards, Der Unwissende

[ADD]
If HD_source is non-nullable, you probably should ensure that getHTML returns a valid string (<> '')
[/ADD]
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#3

Re: TStringStream to BlobStream

  Alt 9. Jan 2007, 19:24
The 2nd parameter of CopyFrom() (the size) can be zero, if you want to copy the whole passed stream. In this case, the source stream will also be seeked to position 0 before copy. Otherwise (if you pass any size value > 0), you have to ensure that the read position is as expected on zero position before calling CopyFrom()
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz