dotnet / dotnet/SqlClient

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

Open
#3,723 2 comments 0 reactions 1 assignee Claimed by @apoorvdeshmukh View on GitHub
Area\Vector
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 19h
Merged PRs (30d)
72

Description

### 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 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
```c#
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`

### 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.