Answered by:
[BC30002] Type 'image' is not defined

Question
-
User497951735 posted
Hi,
I am using SQL Server Business Intelligence Development Studio to create a SSRS report with an image in the page header changed on different pages.
In the report 'custome code', I wrote below:
Public Shared Dim MyImg as String
Public Function SetMyImg (ByVal var as Image)
MyImg =ImageToBase64(var , System.Drawing.Imaging.ImageFormat.Jpeg)
End Function
Public Function ImageToBase64(ByVal mImage As Image, ByVal format As System.Drawing.Imaging.ImageFormat) As String
Using ms As New MemoryStream()
mImage.Save(ms, format)
Dim imageBytes As Byte() = ms.ToArray()
Dim base64String As String = Convert.ToBase64String(imageBytes)
Return base64String
End Using
End Function
In sql server table, I store the image as "varbinary".
In "References" of the "Custom Code", I added "System.Drawing" as reference, but when I preview the report, I got error message "[BC30002] Type 'image' is not defined".
Thank you in advance! :)
Monday, August 18, 2014 12:43 PM
Answers
-
User281315223 posted
Is there a particular line that is triggering this message?
In general, if you included the System.Drawing library as a reference, you shouldn't have any issues with using the Image class (without having to fully qualify it as System.Drawing.Image). You may need to ensure that you have the appropriate Imports statement to use the library as well :
Imports System.Drawing
Do you have any additional information regarding your exact error or where it is being triggered from?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 18, 2014 12:47 PM -
User497951735 posted
Hi, Rion,
I referenced the link below to do my SSRS report:
Thanks! :)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 18, 2014 1:15 PM
All replies
-
User281315223 posted
Is there a particular line that is triggering this message?
In general, if you included the System.Drawing library as a reference, you shouldn't have any issues with using the Image class (without having to fully qualify it as System.Drawing.Image). You may need to ensure that you have the appropriate Imports statement to use the library as well :
Imports System.Drawing
Do you have any additional information regarding your exact error or where it is being triggered from?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 18, 2014 12:47 PM -
User497951735 posted
Thanks, Rion,
The line that triggers the error message is:
Public Function SetMyImg (ByVal var as Image).
If I changed "Image" to "Object", the report works well in develop mode. But once we move the report the production server, the image in the page header doesn't change with the changing content in different pages. Other fields on the page header are string type, they are working fine - changes with the changing content in different pages, only image field doesn't work. That why I am thinking to change image to string.
I tried to put "Imports System.Drawing" at the every beginning of the code. But I got error message:"[BC30465] 'imports' statements must precede any declarations".
Thanks again for your kindly help!
Monday, August 18, 2014 1:05 PM -
User497951735 posted
Hi, Rion,
I referenced the link below to do my SSRS report:
Thanks! :)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 18, 2014 1:15 PM