Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting this error

Inconvertible type mismatch between SourceColumn 'book_image' of Byte[] and the DataColumn 'book_image' of Object.

My database datatype is BLOB for the image.

All of my screenshots of errors are in imgur over here >> the screenshots - Album on Imgur[^]


For each screenshot i wrote a description to describe the problem..

And finally the stack trace:

C#
System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=Inconvertible type mismatch between SourceColumn 'book_image' of Byte[] and the DataColumn 'book_image' of Object.
  Source=System.Data
  StackTrace:
       at System.Data.Common.DataColumnMapping.GetDataColumnBySchemaAction(String sourceColumn, String dataSetColumn, DataTable dataTable, Type dataType, MissingSchemaAction schemaAction)
       at System.Data.Common.DataColumnMapping.GetDataColumnBySchemaAction(DataTable dataTable, Type dataType, MissingSchemaAction schemaAction)
       at System.Data.Common.DataColumnMappingCollection.GetDataColumn(DataColumnMappingCollection columnMappings, String sourceColumn, Type dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
       at System.Data.Common.DataTableMapping.GetDataColumn(String sourceColumn, Type dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
       at System.Data.ProviderBase.SchemaMapping.SetupSchemaWithoutKeyInfo(MissingMappingAction mappingAction, MissingSchemaAction schemaAction, Boolean gettingData, DataColumn parentChapterColumn, Object chapterValue)
       at System.Data.ProviderBase.SchemaMapping..ctor(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, Boolean keyInfo, SchemaType schemaType, String sourceTableName, Boolean gettingData, DataColumn parentChapterColumn, Object parentChapterValue)
       at System.Data.Common.DataAdapter.FillMappingInternal(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
       at System.Data.Common.DataAdapter.FillMapping(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
       at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
       at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at Library_Management_System.LMSDataSetTableAdapters.BooksTableAdapter.Fill(BooksDataTable dataTable) in C:\Users\laptop\Desktop\convert to materialskin\Library Management System\Library Management System\LMSDataSet.Designer.cs:line 4761
       at Library_Management_System.BookReport.BookReport_Load(Object sender, EventArgs e) in C:\Users\laptop\Desktop\convert to materialskin\Library Management System\Library Management System\BookReport.cs:line 23
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException: 


So based on the imgur screenshots and the stack trace, could you guys help me out please?

I am trying to display my images into the report viewer...

What I have tried:

I've provided clear information on how to help me :)

Since i've no idea what to do with this error, I haven't attempted anything yet..just waiting for someone to help me in the right direction
Posted
Updated 3-Apr-20 4:33am
v2

1 solution

An error message is quite clear.
The data type of 'book_image' field in the database is different then the data type of that field in the datatable object. Change it to proper data type.
 
Share this answer
 
Comments
Shawn Law 3-Apr-20 12:34pm    
How? I don't know how to change the datatype so they match

Are you saying that I should change the datatable datatype? How do I do that? I want to make it a byte[] byte array
Maciej Los 3-Apr-20 12:49pm    
Are you saying that I should change the datatable datatype?

Yes!
I want to make it a byte[] byte array

No! If you would like to load data into datatable, it should be object!
Shawn Law 3-Apr-20 13:01pm    
I'm not really following..

Looking at my imgur picture 3..where I highlight the System.Object i understand from here that visual studio sees it as an Object..

I want to display my image which is a byte[] array into the report viewer..

So the picture from database is a byte[] array but i need to convert the Object into a compatible type..

How do I make it compatible? I don't really know how

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900