Insert image to crystal reports

后端 未结 1 1405
悲&欢浪女
悲&欢浪女 2020-12-12 07:38

Insert image to crystal report I have ADO.NET data connection where i\'m using



        
相关标签:
1条回答
  • 2020-12-12 08:36

    I am not sure if i understood your question, but let me share something that may lead you to something useful. I understand you said there is no "backending code", but i hope this may contain some useful tip for your case.

    When we use an image in Crystal Reports, it's type is base64Binary in the XSD.

    In the dataset, it's type is byte[].

    We save the image as a serialized string in the database. Something like that:

    FileStream stream = new FileStream(filePath, FileMode.Open);
    BinaryReader binreader = new BinaryReader(stream);
    byte[] buffer = new byte[(int) stream.Length];
    buffer = binreader.ReadBytes((int) stream.Length);
    string serialized = Convert.ToBase64String(buffer)
    

    We get it back as a byte array to put in the dataset:

    byte[] buffer = Convert.FromBase64String(serialized)
    

    In the Crystal Report design tool, we just drag the field to the document.

    0 讨论(0)
提交回复
热议问题