创建从SQL到图片的Blob流

时间:2019-02-22 10:22:18

标签: c++ builder

我需要从cpp导入数据,而不是dfm文件。

现在我有这样的东西:

bool __fastcall TBrowseXXX::ShowImage(bool Load)
{
float h,w,Ih,Iw,p,r;
AnsiString s = "";
if(MyState!=MS_SHOWN) return false;
LabelImage->Visible = false;
if(DataZDJECIA->DataSet->FieldByName("X_ZDJECIE")->IsNull==false){
    Image1->Visible = false;
    if(Load==true){

        TStream *Stream = DataZDJECIA->DataSet->CreateBlobStream(DataZDJECIA->DataSet->FieldByName("X_ZDJECIE"), bmReadWrite);
              Image1->FileName = DB.GetFile("esystem","TOWPLIKI","PLIK",DataZDJECIA->DataSet->FieldByName("REF")->AsInteger);
        try{
            if (Stream) {
                Image1->Picture->LoadFromStream(Stream);
                Image1->Visible = true;
            }
        }catch(...){
        }
        delete Stream;
    }
   Image1->Visible=true;
   return Image1->Visible;
   }

但是我不想在dfm文件中使用对象:

尝试一下

   bool __fastcall TBrowseTOWARY::ShowImage(bool Load)
   {
   float h,w,Ih,Iw,p,r;
   if(MyState!=MS_SHOWN) return false;
   LabelImage->Visible = false;

   AnsiString SQL = "select X_ZDJECIE from TOWPLIKI where ref = 5982";
   TStream *image;
   TStringList *sql;
   sql = new TStringList;
   sql->Add(SQL);

  if(DB.OpenQuery("esystem","TOWPLIKI",sql)) {
  DB.CheckDataSetActive(DB.GetQuery("esystem","TOWPLIKI"));
    image = DB.GetQuery("esystem","TOWPLIKI")->DataSet->CreateBlobStream(DB.GetQuery("esystem","TOWPLIKI")->DataSet->FieldByName("X_ZDJECIE"), bmReadWrite);
    DB.CloseQuery("esystem","TOWPLIKI");
  }

  delete sql;
  Image1->Picture->LoadFromStream(image);
 Image1->Visible=true;
 return Image1->Visible;
 }

我有[BCC32错误] Browtowary.cpp(359):E2316'DataSet'不是'TDataSet'的成员:(

0 个答案:

没有答案