Image from database field URL

edited 5:21AM in FastReport .NET
Hello everyone.
I am having an issue here. Help me please.

Everything else is OK, but I can't display image which has URL in database field.
I mean I would like to show one or more image in report, and image URL is in database IMG_URL field.

Databinding code is here:
string AliasName = "VW";
                    string FilePath = "../Report/M5400.frx";
                    string SQL = "SELECT * FROM asap.vw5400_print WHERE bnohistory_id = 121212";
                    DataTable dt = Services.Database.ExecuteQuery(SQL).Tables[0];

                    WebReport1.Report = new FastReport.Report();
                    WebReport1.Report.RegisterData(dt, "VW");
                    WebReport1.ReportDataSources = "VW";
                    WebReport1.ReportFile = FilePath;

In report file, image object's datafield value is here [VW.img_url]
But I realise it displays only blob or clob or byte image.
How I could fix this issue.
Thanks

Comments

  • pinbotpinbot Texas
    edited 5:21AM

    I do something similar except that I call a special thumnail URL to resize the picture before placing in on the report.

    Add an PictureObject on your report.
    Select it.
    Create a "BeforePrint" event handler.

    Here is my handler. It reads the URL from a field in the report, appends some properties to the URL (to thumbnail the picture) and then changes the "ImageLocation" of the PictureObject. FastReports will go out, retrieve the picture and put it in the report. Pretty cool, huh?


    private void PropertyPicture_BeforePrint(object sender, EventArgs e)
    {
    string URL1;

    URL1=((String)Report.GetColumnValue("Query1.AptPictureURL"));
    URL1+="&w="+Convert.ToInt32(PropertyPicture.Width).ToString()+"&h="+Convert.ToInt32(PropertyPicture.Height).ToString();
    PropertyPicture.ImageLocation=URL1;
    }


    You could probably just do something like

    MyPicture.ImageLocation=((String)Report.GetColumnValue("myquery.myfield"));

    in your BeforePrint handler.

    I think you'll find it works quite well.

    Bryan



  • edited 5:21AM
    And is it possible to map binary field automatically to image, please?
  • edited 5:21AM
    Hello,

    Picture1.Image = new Bitmap(new MemoryStream(here_is_your_byte[]_array));

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.