Hi!
Im working with VS2005 and I have created a winforms application that uses
the reportviewer to show a report. I have a header with some text, a table
which I populate from a datasource, and an image which I also need to
populate from a datasource. The problem is that the image doesnt show, all I
get is a red X
I ahve found no example code anywhere on msdn that show how to display jpegs
from a database... So I have played with the code for about 2 days, and now I
give up. I have read all documentation regarding images from database that I
found on msdn.
---------------------------------------------------------
Here is some code:
_reportViewer.LocalReport.DataSources.Add(New
ReportDataSource("ReportData_Table", _bodyDs.Tables(0)))
_reportViewer.LocalReport.DataSources.Add(New
ReportDataSource("ReportData_TablePicture", _pictureDs.Tables(0)))
----------------------------------------------------------
The _pictureDs.Tables(0) dataset contains one column called "BLOB" which
contains the jpeg picture. I have configured the image as follows:
MIMEType: image/jpeg
Source: Database
Value: =Fields!BLOB.Value
One thing puzzles me. I dont specify a datasource, as I do with the table
object, does the reportviewer search in both databases for a column called
BLOB? Or how is it supposed to work? Im very puzzled by this.
---------------------------------------------------------------------
Her eis some xml code from the report:
<Image Name="imgPAM">
<Sizing>AutoSize</Sizing>
<Left>8cm</Left>
<MIMEType>image/gif</MIMEType>
<Top>2.75cm</Top>
<ZIndex>5</ZIndex>
<Width>6.5cm</Width>
<Source>Database</Source>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Height>6.25cm</Height>
<Value>=Fields!BLOB.Value</Value>
</Image>
--------------------------------------------------------------------
The datasource section:
<DataSets>
<DataSet Name="ReportData_Table">
<rd:DataSetInfo>
<rd:DataSetName>ReportData</rd:DataSetName>
<rd:TableName>Table</rd:TableName>
</rd:DataSetInfo>
<Query>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<CommandText />
<DataSourceName>DummyDataSource</DataSourceName>
</Query>
<Fields>
<Field Name="SITE_CODE">
<rd:TypeName>System.String</rd:TypeName>
<DataField>SITE_CODE</DataField>
</Field>
<Field Name="tool_part_no">
<rd:TypeName>System.String</rd:TypeName>
<DataField>tool_part_no</DataField>
</Field>
<Field Name="class">
<rd:TypeName>System.String</rd:TypeName>
<DataField>class</DataField>
</Field>
<Field Name="description">
<rd:TypeName>System.String</rd:TypeName>
<DataField>description</DataField>
</Field>
<Field Name="tool_unit_code_descr">
<rd:TypeName>System.String</rd:TypeName>
<DataField>tool_unit_code_descr</DataField>
</Field>
<Field Name="A">
<rd:TypeName>System.String</rd:TypeName>
<DataField>A</DataField>
</Field>
<Field Name="B">
<rd:TypeName>System.String</rd:TypeName>
<DataField>B</DataField>
</Field>
</Fields>
</DataSet>
<DataSet Name="ReportData_TablePicture">
<rd:DataSetInfo>
<rd:DataSetName>ReportData</rd:DataSetName>
<rd:TableName>TablePicture</rd:TableName>
</rd:DataSetInfo>
<Query>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<CommandText />
<DataSourceName>DummyDataSource</DataSourceName>
</Query>
<Fields>
<Field Name="BLOB">
<rd:TypeName>System.Byte</rd:TypeName>
<DataField>BLOB</DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
-----------------------------------------------------------------------
I need urgent help on this, I thought it was really simple to add a picture
to a report... lolz!
/Henrik
Henrik Nordgren - 28 Dec 2006 10:25 GMT
Hi!
I solved the error (possible bug in the reportviewer???) by creating a table
instead where I added an image in a single column, and voíla it worked!!!
kind regards
Henrik

Signature
.NET Developer
> Hi!
>
[quoted text clipped - 117 lines]
> to a report... lolz!
> /Henrik