Autor Beitrag
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 25.11.02 15:13 
Hi Leute,

sonst habe ich immer übereine BDE-Connection ein Jpeg mit folgendem Code aus einem Blob-Field ausgelesen (Auszug aus einer Funktion):
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
          TmpJPeg := TJPEGImage.Create;
          blob := TBlobStream.Create(Query1.FieldByName(FieldName) as TBlobField, bmRead);
          try
            try
              TmpJPeg.LoadFromStream(Blob);
              result := TmpJPeg;
            except
              result := nil;
              raise;
            end;
          finally
            Blob.free;
          end;


unter Interbase mit direkter Verbindung ohne Bde bekommich immer den Fehler:
Zitat:
"Ungültige Typenumwandlung"

Was kann ich tun ?

(26.11. 09:25 Tino) Code-Tags hinzugefügt.

_________________
DataCool
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 25.11.02 16:59 
Hi!

Du benutzt also nun was anderes als die BDE, ja? Also DBX oder andere Komponenten. Hast du denn wirklich alle Komponenten ausgetauscht?
Ist Query1 garantiert nicht mehr das TQuery-Objekt?

Cu,
Udontknow
DataCool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 25.11.02 17:24 
Ja, ich habe definitiv alle Komponenten ausgetauscht !
Ich benutze nämlich für alle Datenbank-Anwendungen eine generelle Datenbank-Klasse, die Intern jeweils die richtigen Datenbank-Object verwendet !

_________________
DataCool
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 25.11.02 17:32 
Hmmm, frage ich mal anders: Von welchem Typ ist Query1?

Cu,
Udontknow
DataCool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 25.11.02 17:34 
Von Typ TIBQuery

_________________
DataCool
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 25.11.02 17:50 
Aus der Delphi-Hilfe:
Zitat:

TBlobStream

Beschreibung

Mit TBlobStream können die Werte eines BLOB-Feldes in einer BDE-aktivierten Datenmenge verfügbar gemacht...


Du hast keine BDE-Komponenten, also darfst du auch nicht TBlobStream benutzen. Stattdessen schaue mal bei TIBBlobStream nach.

Cu, :D
Udontknow
DataCool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 26.11.02 09:51 
Mit IBBlobStream hab ich es auch schon versucht, aber ich bekomme es damit nicht hin :?: :!: :cry:

_________________
DataCool
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 26.11.02 12:01 
Hi
die Variante funktioniert sowohl mit BDE als auch mit IBX:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
   if  not BildFeld.IsNull then begin
       Daten  := TMemoryStream.Create;
       Bild  := TJpegImage.Create;
       BildFeld.SaveToStream(Daten);
       Daten.Position := 0;
       Bild.LoadFromStream(Daten);
       Daten.Free;
       ....
   end;


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
DataCool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 26.11.02 12:19 
Von welchem Typ ist Deine Var Bildfeld ?

ich bekomme nämlich immer bei :
BildFeld.SaveToStream(Daten);
eine Schutzverletzung :cry:

_________________
DataCool
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 26.11.02 13:04 
Hi
BildFeld ist vom Typ TBlobField. Die Bilddaten wurden vorher auf die gleiche Art und Weise in der Datenbank abgelegt.
ausblenden Quelltext
1:
2:
3:
4:
5:
       img.Picture.LoadFromFile(dlg.FileName);
       BildDat := TMemoryStream.Create;
       img.Picture.Graphic.SaveToStream(BildDat);
       bildDat.Position := 0;
       BildFeld.LoadFromStream(BildDat);


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
Sephiroth
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 102



BeitragVerfasst: Di 26.11.02 14:40 
Also ich benutzte zwar IBO statt IBX aber denke das macht keinen Unterschied. Ich hab ebenfalls eine Routine um ein Bild in eine Datei abzuspeichern (kann man ja abändern für deine Zwecke)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure ReadImage(strPfad : String);
var stmImage: TMemoryStream;
    BlobField: TIB_Column;
begin
  stmImage   := TMemoryStream.Create;
  try
    with dmHaupt, dmHaupt.qryIBQuelle do begin
      BlobField:=FieldByName('BILD');
      BlobField.AssignTo(stmImage);
      if not BlobField.IsNull then stmImage.SaveToFile(strPfad);
    end;
  finally
    stmImage.Free;
  end;
end;


Hoffe das kann helfen.