Skip to content

Fix | Allow writing DateOnly instance as a Variant parameter#4294

Open
edwardneal wants to merge 1 commit into
dotnet:mainfrom
edwardneal:fix/issue-3953
Open

Fix | Allow writing DateOnly instance as a Variant parameter#4294
edwardneal wants to merge 1 commit into
dotnet:mainfrom
edwardneal:fix/issue-3953

Conversation

@edwardneal
Copy link
Copy Markdown
Contributor

Description

This resolves an issue described in #3953: when passing a DateOnly instance as a parameter with a SqlDbType of Variant, the current response is an exception with message:

The incoming tabular data stream (TDS) protocol stream is incorrect. The stream ended unexpectedly.

This exception is legitimate, and it's a result of WriteSqlVariantValue and WriteSqlVariantDataRowValue not containing a code path which writes the data - so we're only sending the sql_variant header. Adding these code paths resolves the issue and eliminates the exception.

Issues

Fixes #3953.

Testing

The existing DateTimeVariantTests have been modified to add test coverage.

@edwardneal edwardneal requested a review from a team as a code owner May 17, 2026 18:34
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board May 17, 2026
@ErikEJ
Copy link
Copy Markdown
Contributor

ErikEJ commented May 18, 2026

@edwardneal Would this also fix #3934 ?

@edwardneal
Copy link
Copy Markdown
Contributor Author

While it's definitely a good idea to retest once CI has run, I don't know if it'll fix that specific issue. I wasn't able to reproduce it in the first instance, and only bumped into this while testing other scenarios adjacent to it. There are a pair of currently-unreported bugs which crop up when sending DateOnly instances as values in a sql_variant TVP field, and if that code path is being exercised then the #3934 will need a deeper fix.

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

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

Cannot send DateOnly instance as a SqlDbType.Variant-typed parameter

2 participants