Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

TBlobField / Dateien aus DB

Empfohlene Antworten

Hi!

Ich habe einen kleinen E-Mail-Client mit dem C++-Builder 5 geschrieben und sämtliche E-Mail-Bodys und Attachments werden in einer MySQL DB gespeichert!

Jetzt habe ich das Problem, die Attachments aus der DB zu bekommen! Hier meine beiden Versuche:

 

void __fastcall TFrMain::Attachments1Click(TObject *Sender)

{

  int egnr = SgMail->Cells[0][SgMail->Row].ToInt();

  TBlobField *b;



  QrAttach->SQL->Clear();

  QrAttach->SQL->Add("select * from attachments");

  QrAttach->Open();

  b = QrAttach->FieldByName("attach");

  b->SaveToFile(QrAttach->FieldByName("filename")->AsString);

  QrAttach->Close();

}
Das Problem ist, dass er hier nicht das TField (QrAttach->FieldByName("attach");) in ein TBlobField konvertieren kann! Kann mir da vielleicht jemand helfen? Mein zweiter Versuch sieht so aus:
 int egnr = SgMail->Cells[0][SgMail->Row].ToInt();

  QrAttach->SQL->Clear();

  QrAttach->SQL->Add("select * from attachments");

  QrAttach->Open();

  if (QrAttach->FieldByName("ategnr")->AsInteger == egnr)

  {

    TStream * a = QrAttach->CreateBlobStream(QrAttach->FieldByName("attach"),bmReadWrite);

    if (a->Size >0)

    {

      void *temp = new char[a->Size]; //wenn ja Speicher anlegen

      a->ReadBuffer(temp, a->Size);   //Auslesen

      TMemoryStream * m = new TMemoryStream();

      m->LoadFromStream(a);

      m->SaveToFile("C:\\hoschi.xls");

    }

    delete a;

QrAttach->Close();

Hier bekomme ich in der Zeile (TStream * a = QrAttach->CreateBlobStream(QrAttach->FieldByName("attach"),bmReadWrite);) den Fehler 'QrAttach: Dataset not in edit or insert mode'!!!

Danke schon mal für die Hilfe!

Gruß

Hoeen

***sichselbstindenhinterbeiss*** wie doooooof von mir!

also hier der korrekte Code:

int egnr = SgMail->Cells[0][SgMail->Row].ToInt();

  TBlobField *b;



  QrAttach->SQL->Clear();

  QrAttach->SQL->Add("select * from attachments");

  QrAttach->Open();

  b = (TBlobField *)QrAttach->FieldByName("attach");

  b->SaveToFile(QrAttach->FieldByName("filename")->AsString);

  QrAttach->Close();

Ich habe einfach nur (TBlobField *) vergessen! tss...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.