Hi,
I’m new to LLBLGen Pro, currently evaluating it. I’m using the October 17th Final 2.0.0.0 version on .NET 2.0 Framework and SQL Server 2005 Database.
I’m trying to databind an entity collection to a DataGridView via a BindingSource. One of the fields is an image, System.Byte array .NET data type mapped in a varabinary(max) column. The code is pretty simple:
Dim adapter As New DataAccessAdapter()
Dim chapter As New ChapterEntity(chapterEx.ChapterId)
adapter.FetchEntity(chapter)
adapter.FetchEntityCollection(chapter.ClusterCollectionViaChapterCode, chapter.GetRelationInfoClusterCollectionViaChapterCode)
ClustersBindingSource.DataSource = chapter.ClusterCollectionViaChapterCode
The problem is that as soon as I set the DataSource property, I get exceptions from the DataGridView while trying to bind each image. By handling the DataError event I captured the following Message of the exceptions:
Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.ImageConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.Windows.Forms.Formatter.FormatObjectInternal(Object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, String formatString, IFormatProvider formatInfo, Object formattedNullValue)
at System.Windows.Forms.Formatter.FormatObject(Object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, String formatString, IFormatProvider formatInfo, Object formattedNullValue, Object dataSourceNullValue)
at System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value, Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
So, do I need to provide a custom implementation of a TypeConverter for the image field or am I doing something wrong?
Thanx,
Manos