Skip to content

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

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)

Activity

  1. apoorvdeshmukh commented on Oct 27, 2025

    @apoorvdeshmukh
    Contributor

    Thank you @Rubydesic for opening this issue.
    This scenario is currently not supported with SqlVector type due to certain limitations with DataTable and the implementation of vector datatype.
    VECTOR datatype is supported only through SqlVector class and no CLR type such as byte[] is supported that can be used as an alternative to SqlVector when working with DataTable scenarios such as this one.
    However, I have noted this as an enhancement request.

  2. moved this from To triage to Backlog in SqlClient Boardon Oct 27, 2025
  3. added
    Area\Vector
    on Oct 27, 2025
  4. Rubydesic commented on Oct 27, 2025

    @Rubydesic
    Author

    @apoorvdeshmukh What is the limitation? It is possible to manually construct a DataTable with a column that has a SqlVector<float> data type.

  5. moved this from Backlog to To triage in SqlClient Boardon Oct 28, 2025
  6. changed the issue type fromtoon Nov 20, 2025
  7. moved this from To triage to Backlog in SqlClient Boardon Nov 20, 2025
  8. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  9. github-actions commented on Sep 17, 2026

    @github-actions

    Generated by SqlClient Issue Auto-Triage for #3723 · copilot · auto · 76.2 AIC · ⌖ 13.2 AIC · ⊞ 11.9K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area\Vector

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions