Autor Beitrag
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 13:58 
Was ist w bei While HexStream.Read (w, SizeOf (Word)) = SizeOf (Word) do Begin?

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 16.04.07 14:03 
:oops: sollte 'p' heißen

_________________
Na denn, dann. Bis dann, denn.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 14:15 
Ich bekomme eine Zugriffsverletzung bei 'OutStream.Seek (0, soFromBeginning);'.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
    Function HexStreamToByteStream (HexStream, OutStream: TStream):TMemoryStream;
    Var
      p : Word;
      b : Byte;

      function HexChar(c: Byte): Byte;
      begin
        case Chr(c) of
          '0'..'9':  Result := Byte(c) - Byte('0');
          'a'..'f':  Result := (Byte(c) - Byte('a')) + 10;
          'A'..'F':  Result := (Byte(c) - Byte('A')) + 10;
        else
          Raise Exception.Create('Ungültiges HEX-Format')
        end;
      end;


      function HexByte(p: Word): Byte;
      begin
        Result := (HexChar(p shr 8shl 4) + HexChar(p and $FF);
      end;


    Begin
      OutStream.Seek (0, soFromBeginning);
      HexStream.Seek (0, soFromBeginning);
      While HexStream.Read (p, SizeOf (Word)) = SizeOf (Word) do Begin
        b := HexByte (p);
        OutStream.Write (b, SizeOf (b));
      End;
      Result.CopyFrom(OutStream,0);
    End;

Aufruf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
LoadStream := TMemoryStream.Create;
LoadStream := HexStreamToByteStream (CreateBlobStream(FieldByName('FAST_REPORT'),bmRead),nil);
MainFstRpt.LoadFromStream(LoadStream);
LoadStream.Free;

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 16.04.07 14:18 
erm... warum nicht den BlobTyp in der Datenbank ändern, so dass die DB nix ändert ? Meine Streams ändern sich da nämlich ned :P

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 14:20 
user profile iconHelgeLange hat folgendes geschrieben:
erm... warum nicht den BlobTyp in der Datenbank ändern, so dass die DB nix ändert ? Meine Streams ändern sich da nämlich ned :P


Hatte ich schon versucht. Am Typ liegt es nicht.

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 16.04.07 14:21 
mexx: Du übergibst ja auch 'nil' als OutStream :autsch:

_________________
Na denn, dann. Bis dann, denn.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 16.04.07 14:27 
mal die connection-settings angeschaut ? es gibt einen Verbindngs-parameter bei firebird, wo man charset angeben kann, vielleicht hat sich da was eingeschlichen. auch mal charset setting der db selbst überprüfen.
poste doch mal die tabellen-definition

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 14:33 
@HelgeLange:Der Verbindungsaufbau passiert über die BDE. Leider kann ich mich nicht von Ihr trennen. Ich kann aber durchaus andere Felder mit Umlauten belegen, was mir zeigt, dass es daran nicht liegen kann. Ich kann auch andere Blobfelder mit Umlauten belegen. Die bekommen, aber die Daten anders. Deswegen meine Theorie, dass es an dem Blobtransfer liegt.

@alzaimer:
Ich verstehe nicht, warum Du die Ausgabe als Input-Parameters der Funktion deklarierst. Ich habe das mal so gemacht, erhalte aber die Zugriffsverletzung.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
    
Function HexStreamToByteStream (HexStream: TStream):TMemoryStream;
    Var
      p : Word;
      b : Byte;
      OutStream: TStream;

      function HexChar(c: Byte): Byte;
      begin
        case Chr(c) of
          '0'..'9':  Result := Byte(c) - Byte('0');
          'a'..'f':  Result := (Byte(c) - Byte('a')) + 10;
          'A'..'F':  Result := (Byte(c) - Byte('A')) + 10;
        else
          Raise Exception.Create('Ungültiges HEX-Format')
        end;
      end;


      function HexByte(p: Word): Byte;
      begin
        Result := (HexChar(p shr 8shl 4) + HexChar(p and $FF);
      end;


    Begin
      OutStream.Seek (0, soFromBeginning);
      HexStream.Seek (0, soFromBeginning);
      While HexStream.Read (p, SizeOf (Word)) = SizeOf (Word) do Begin
        b := HexByte (p);
        OutStream.Write (b, SizeOf (b));
      End;
      Result.CopyFrom(OutStream,0);
    End;

Aufruf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
          LoadStream := TMemoryStream.Create;
          LoadStream := HexStreamToByteStream (CreateBlobStream(FieldByName('FAST_REPORT'),bmRead));
          MainFstRpt.LoadFromStream(LoadStream);
          LoadStream.Free;

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 16.04.07 14:34 
user profile iconmexx hat folgendes geschrieben:

@alzaimer:
Ich verstehe nicht, warum Du die Ausgabe als Input-Parameters der Funktion deklarierst. Ich habe das mal so gemacht, erhalte aber die Zugriffsverletzung.

'Function' ist falsch, es muss 'Procedure' heißen...

_________________
Na denn, dann. Bis dann, denn.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 14:37 
Ich brauche doch aber eine Ergebnismenge aus der Operation HexStreamToByteStream?!

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 16.04.07 14:49 
In HexStream,
Out OutStream

_________________
Na denn, dann. Bis dann, denn.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 14:51 
Aber wie soll dann der Aufruf aussehen?

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 16.04.07 15:26 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Procedure HexStreamToFastReportStream (HexStream, OutStream : TStream);
Begin
...
End;

Var
  S : TMemoryStream;

Begin
  S := TMemoryStream.Create; 
  HexStreamToFastReportStream (HexStreamAlsBlobStream,S);
  FastReport.LoadFromStream (S);
End;

Dich stört bestimmt, das es kein 'Var OutStream' ist. Na ja, der Stream (die Instanz) wird ja nicht verändert, sondern nur sein Inhalt. Wenn Du ein Glas Bier auffüllst, ändert sich der Inhalt, aber das Glas ist noch das Selbe.

_________________
Na denn, dann. Bis dann, denn.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Mo 16.04.07 15:47 
Ja, ich hatte das Var vermisst. Der Aufruf geht und die While-Schleife läuft durch, aber LoadStream scheint leer zu bleiben. Es wird kein Report geladen. Die Datenbank hat aber einen HEX-Code. Wie kann ich prüfen, ob die Ergebnissmenge OutStream/LoadStream etwas enthält?

Wenn ich beim Report SaveToStream mache, in welcher Form befinden sich dann die Daten? Ist das wie ein Textfeld zu verstehen, dass den XML-Code enthält, oder ist es BIN-Code?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
    Procedure HexStreamToByteStream (HexStream, OutStream: TStream);
    Var
      p : Word;
      b : Byte;

      function HexChar(c: Byte): Byte;
      begin
        case Chr(c) of
          '0'..'9':  Result := Byte(c) - Byte('0');
          'a'..'f':  Result := (Byte(c) - Byte('a')) + 10;
          'A'..'F':  Result := (Byte(c) - Byte('A')) + 10;
        else
          Raise Exception.Create('Ungültiges HEX-Format')
        end;
      end;


      function HexByte(p: Word): Byte;
      begin
        Result := (HexChar(p shr 8shl 4) + HexChar(p and $FF);
      end;


    Begin
      OutStream.Seek (0, soFromBeginning);
      HexStream.Seek (0, soFromBeginning);
      While HexStream.Read (p, SizeOf (Word)) = SizeOf (Word) do Begin
        b := HexByte (p);
        OutStream.Write (b, SizeOf (b));
      End;
    End;

Aufruf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
          LoadStream := TMemoryStream.Create;
          HexStreamToByteStream (CreateBlobStream(FieldByName('FAST_REPORT'),bmRead), LoadStream);
          MainFstRpt.LoadFromStream(LoadStream);
          LoadStream.Free;

_________________
Das Unsympathische an den Computern ist, dass sie nur ja oder nein sagen können, aber nicht vielleicht.