如何在 asp.net 报告查看器中显示数据库中保存的二维码

How to show saved QR Code from database in asp.net report viewer

场景如下:

我正在使用 https://github.com/jeromeetienne/jquery-qrcode 生成二维码并将其保存到数据库中。

现在,我必须在 asp.net 中使用报表查看器 (rdlc) 显示它。

数据库中的数据类型为 varchar(max),其值的保存方式之一示例为:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAALsElEQVR4Xu2d23bjOgxD2///6J6VidtxLYvgJuUkZ4K+WtYFBMGLHffz4+Pj6+MBf19ff5f5/PxMr7i/T93Umfd4b3Zdcp/aX3bNGw7RXNE8ag8K4+z1m4VNrBNDZY1sYp1TzcTacCEE2UNJ7lNqkSWzFWtnAYfCOHzdoPqniUUOF8XbyJOVl++vH/dTzS1UbkD2G81F9qv2RNbJzqWwz85zHHecdwiFJtYdslUKq8Jf1ZBVO5lYG+JEAapgn+UsJhajPFIs4m2KAB2jZ0Ou2gMJLdmzq3OtCt2dUB05ySrMTKwJu6oAm1h3QE0sE+sXAlWHUnlomLxnw8FZqXxVkhhVI6tAUn2i/R6sWC+kWIp0UbuBpJSd/Cbb8lDE2u+XOKo6J3ls8zY5lomlaKOvm1gnbQMTSxNHjTCxTKwfjjgUblAQIFTifFXDsZrjVO9T1VCEg8KI9NmUos2uk2ih1ohs+pSq8CrCKiCqRQFpTppYW5V4fB/rEcpiYp2X6G+jWEoBouvEy4/zEHJXx0b9MHJuFVJJy+OqsVHLQ+0/iwXqvGcnPRtnYmlVIjlXZ6yJlaggV6mbFeuOgBVrIp8OhSMw1R7Xygj1Eu+8dyqp6uMKFVqy85LyfdWaNwJkHzmp9kiHTGGO/Qq/0jGxxrD0KMKaWBsCpCh4BGEfRYCrzmJimVi/OPDyofBrVVnQoL7y+mq5/Kh5o6NnczVapT4jQScm/jSxzvtNxHAm1oiAiZUIsVRN9uOtWAmde1RoIWpR7WOp55VkDzMiKUivwlOtG6UWWfU9tjwG5yOh8CogVs1LyELGEsUiKeuqcxM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IRd5uqBpRhQDl9dUQS+YlykLCenVeghnpW6mxxMbRWPQQmizaabxVvWglaFGfyMS6o2NibSypOkZEWOUEVqxEqK4ahsi68oROL626fxPrvH8XKlbnJ/YJLv4MqfaFVoY3pS6z80S5WiePqxJd4V49J21pmFiJUJgtEI6KamJNqk0rlvL/+EcFJpaJVf6PZA6FvAeG2g3at3MjVA5QzcdUkbC/TjrXJHkn85KWDClaaK4UtVYizJa1G3K00aNMrGsxMrEm+Fqx9D8SXdWk7ag8qgq1L9VGVEOEUjdSzWUln5xQnWu/fzU22l8nzyOOSvYbjQ0/CkIAVmMJqKsIQLreav+z6+pcxFAmVsEKygCzKa1Yd2SsWIm8ifDSxPpHiFVVFpUEknkJmUj+QEJsdl71yKka3lRlF+Y34Fv4kd1azV/See8ojYmlP29Nnh2aWBsbTSwTiwjTdCwJESqMZlsKZE0Vbh0K2YfXhrBJfqWTNfBtHDFyNG9nnpX37vdImpOz+5T3qr2TUKjWyl4n7Rv0Kx0Ta6zQlPKZWCe5UAc05XFZL+nMs/JeK1b8BZwj1k9RLGJwRW5SFGTJfBbKZ/eq9audd7VXUkGSNktVYYc8+Rk5lomlaKOvm1iJEEuSQtU41CbJjVBK+T2LFescT4fCCc9MrOZXBZ8RCnOacR/VCZtKTcg+ZmPJ/sh6WWJn5iQ4kHWjtstTFCsDxvcYYjgyluwhGnvVmsTA6iwm1glCxHBkrDJG9vpVa5pYJ8k5DWGrFOEqI6/aX5asZ/iRezsFDiF0ORR2DkOMXC2dOwZQ4SH7yIS8WtLBMyILIYPaQ/YZ6RF79KxQbWKVJ5tYHOnq80q1kom1IVT1VivWOcUuI5ZidPW6MmR13mzI6uQdx3urj2mIE6gQW20qq3n3Z1U2C7GP/id01dhn96lNVtcysUbkSGpBxhIHe/mffynCmVgmluJI6bqJ9ZrE+g9z8GiRAlTgVgAAAABJRU5ErkJggg==

我的问题是,如何使用 asp.net 报告查看器在报告中显示此信息?

这是我在浏览器中显示它的方式:

<img src="TheLongStringValueFromDatabase" />

我尝试将其作为图像插入到报表查看器中并设置如下:

  1. MIMEType 到 "image/pmg"

  2. 源数据库

  3. Value(上面提到的值)

感谢任何帮助。

我找到了方法。

我没有将图像保存为 varchar(max),而是需要将其保存为 varbinary(max) 到数据库。为此,我执行了以下操作:

Dim result As String() = qrCodeString.Split(New Char() {","c})    
Dim bytes() As Byte = System.Convert.FromBase64String(result(1))

其中 qrCodeString 是我在原始问题中粘贴的长字符串值。

然后,在报告查看器中,我插入一个 "image" 并像以前一样设置属性,但值除外,它现在的数据类型为 varbinary(max) 并且显示 QR 码现在!