System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: ed5187ead0c3061a3a1f6f7283c94938e38140e3
Title: Binary GUID not converted from Byte[] to GUID
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: Convert Resolution: Works_As_Designed
Last Modified: 2016-03-30 20:46:23
Version Found In: 1.0.99.0
User Comments:
anonymous added on 2016-02-25 15:12:48: (text/x-fossil-plain)
I have a typed DataTable with a column of type GUID (created by dropping the table onto the 
DataSet designer surface). The connection string does not specify the BinaryGuid parameter,
so binary GUIDs are being used.

It seems that the binary GUID is not converted back to a GUID when the DataTable is loaded. I get the following exception:

An exception of type 'System.ArgumentException' occurred in System.Data.dll but was not handled in user code

Additional information: Type of value has a mismatch with column typeCouldn't store <System.Byte[]> in PresetGuid Column.  Expected type is Guid.

   at System.Data.DataColumn.set_Item(Int32 record, Object value)
   at System.Data.DataTable.NewRecordFromArray(Object[] value)
   at System.Data.DataTable.LoadDataRow(Object[] values, Boolean fAcceptChanges)
   at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
   at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
   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)

mistachkin added on 2016-02-25 19:57:16: (text/x-fossil-plain)
Can you please provide the schema for the database table(s) involved?

anonymous added on 2016-02-26 14:36:04: (text/x-fossil-plain)
I can't share the full table here, but it is basically created as:

CREATE TABLE Charges(ChargeId INTEGER PRIMARY KEY UNIQUE, PresetGuid GUID DEFAULT 0)

The DataSet designer creates the DataColumn for PresetGuid with type GUID (as expected).

The table viewer in VS2015 (Server Explorer->Data Connections->Retrieve Data on Charges 
tables) lists the column content as <Unable to read data>.

IIRC setting BinaryGuid=FALSE isn't working either.
Encoding is set to UTF-16.

mistachkin added on 2016-02-26 18:55:04: (text/x-fossil-plain)
I think the "DEFAULT 0" clause may be a problem.  That would have a data affinity of "integer", not BLOB or string.

anonymous added on 2016-03-08 17:42:16: (text/x-fossil-plain)
Yes, but the type conversion exception is byte[] -> Guid:
'Type of value has a mismatch with column type. Couldn't store <System.Byte[]> in PresetGuid Column.  Expected type is Guid.'
So the type returned to the DataTable (by the DataReader?) is byte[] regardless of the column affinity.
Maybe some error path returns a byte[] instead a Guid if the type affinity is not blob?

mistachkin added on 2016-03-10 00:49:26: (text/x-fossil-plain)
For BinaryGUID=true, can you try using:

CREATE TABLE Charges(ChargeId INTEGER PRIMARY KEY UNIQUE, PresetGuid GUID DEFAULT X'00000000000000000000000000000000');