Skip to content

SqlDataAdapter.Fill throws exception with the new VECTOR data type. #3723

@Rubydesic

Description

@Rubydesic

Describe the bug

SqlDataAdapter.Fill throws an exception when filling a column that contains the VECTOR data type

System.ArgumentException: Type of value has a mismatch with column typeCouldn't store <Microsoft.Data.SqlTypes.SqlVector`1[System.Single]> in NameEmbedding Column.  Expected type is Byte[].
 ---> System.ArgumentException: Type of value has a mismatch with column type
   at System.Data.Common.ObjectStorage.Set(Int32 recordNo, Object value)
   at System.Data.DataColumn.set_Item(Int32 record, Object value)
   --- End of inner exception stack trace ---
   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)

To reproduce

var connectionString = "...";
var command = new SqlCommand("SELECT VectorColumn FROM MyTable", new SqlConnection(connectionString));
var adapter = new SqlDataAdapter(command);
var dt = new DataTable();
adapter.Fill(dt); // throws

Expected behavior

It should not throw, and it should populate the DataTable with a column of type SqlVector<float>

Further technical details

Microsoft.Data.SqlClient version: 7.0.0-preview2.25289.6
.NET target: .NET 10
SQL Server version: SQL Server 2025 17.0.925.4
Operating system:

  • C# Client: Windows 11 Version 24H2 (OS Build 26100.6584)
  • SQL Server: Windows Server 2022 Datacenter (10.0)

Metadata

Metadata

Labels

Area\VectorUse this for issues that are targeted for the Vector feature in the driver.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions