Skip to content

Conversation

johnnypham
Copy link
Contributor

@johnnypham johnnypham commented Jun 15, 2021

Fixes #1105

The exception occurs when the driver tries to execute sp_describe_parameter_encryption but no user parameters have been provided.

Current behaviour for always encrypted with secure enclaves:

When executing a stored procedure that does not require an input parameter:

  • unexpected: fails with NRE. Driver attempts to add parameters to execute sp_describe_parameter_encryption but parameters are null. Should succeed by sending empty parameter list for sp_describe_parameter_encryption

When executing a stored procedure that requires an input parameter but none are provided by the user:

  • unexpected: fails with NRE. Driver attempts to add parameters to execute sp_describe_parameter_encryption but parameters are null. Should fail with "Microsoft.Data.SqlClient.SqlException (0x80131904): Procedure or function '[name of sp]' expects parameter '@[name of param]', which was not supplied."

This change fixes both unexpected behaviours above.

@johnnypham johnnypham merged commit ae693c3 into dotnet:main Jul 10, 2021
@johnnypham johnnypham deleted the issue1105 branch July 10, 2021 01:19
DavoudEshtehari pushed a commit to Wraith2/SqlClient that referenced this pull request Sep 1, 2021
…rovided (dotnet#1115)

* Update SqlCommand.cs

* only execute sp_describe_parameter_encryption if parameters not empty

* add test

* improve test coverage

* only go through parameters if not null

* revert previous attempt

* Update ApiShould.cs

* Update ApiShould.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using SqlDataAdapter.Fill on parameter-less stored procedure command with always encrypted w. secure encalves gives NullReferenceException
3 participants