Replies: 1 comment 5 replies
-
We are having the exact same issue porting our .NET 4.8 framework code to .NET 6. Is there any workaround to this issue. It's a real show stopper for us. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is an issue with the .NET 6 SqlDataAdapter class (and possibly .NET 5/.NET Core) that was not present in .NET Framework 4.8. The issue affects batch updates with output parameters. Consider the following code:
When the above code runs under .NET Framework 4.8 it completes successfully. When the above code runs under .NET 6, the following exception is thrown on the last line:
Note that the call to SqlDataAdapter.Update throws the above exception prior to actually calling the stored procedure. Besides the initial call to SqlConnection.Open, SQL Profiler doesn’t show any other activity from the client.
I eventually determined that .NET is somehow switching the SqlDbType from Int (or BigInt or probably every other type) to NVarChar. So one workaround is to specify a Size that can accommodate the max string length for the intended data type. A better workaround that doesn't require converting NVarChar back to the intended data type is to change the parameter direction from Output to InputOutput.
Any efforts to address this issue would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions