Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlConnection.GetSchema cannot get procedure parameters with predefined metadata collection name #575

Closed
mizulily opened this issue May 22, 2020 · 5 comments
Milestone

Comments

@mizulily
Copy link

Description

I tried to get parameters of sql server procedure, so I used GetSchema method as follow:
DataTable dt = connection.GetSchema(SqlClientMetaDataCollectionNames.Parameters);
Then I got an exception telling me the requested collection(Parameters) is not defined.
I am confused because I have already tried collections like Databases/Tables/Procedures/Columns and the collection name is predefined by SqlClientMetaDataCollectionNames class.

Configuration

I am using System.Data.SqlClient 4.8.1 from nuget with project configured as .Net Framework 4.7.

Other information

I reviewed some codes in System.Data and found that this collection name string is both 'ProcedureParameters' in OLEDB and ODBC connection.
So I tried to type 'ProcedureParameters' string straight as parameter of GetSchema and it worked.
DataTable dt = connection.GetSchema("ProcedureParameters");
I think it's a minor bug that you can fix it by updating string mapping in SqlClientMetaDataCollectionNames.cs

@Wraith2
Copy link
Contributor

Wraith2 commented May 23, 2020

/cc @cheenamalhotra

@cheenamalhotra cheenamalhotra transferred this issue from dotnet/runtime May 23, 2020
@karinazhou
Copy link
Member

karinazhou commented May 23, 2020

HI @mizulily,

I quickly checked the Microsoft.Data.SqlClient and found that there is a missing string for "ProcedureParameters" in SqlClientMetaDataCollectionNames.cs . Looks like it's the reason for this issue.

Good catch 👍

Thanks,

@mizulily
Copy link
Author

HI @karinazhou ,
Yes, I think "ProcedureParameters" is missing in SqlClientMetaDataCollectionNames.cs
Furthermore, the predefined string "Parameters" is invalid since it will cause exception.

@karinazhou
Copy link
Member

@mizulily , I also test it with some old SQL Servers such as 2008, 2012, and 2016. All of them give me the same exception to this SqlClientMetaDataCollectionNames.Parameters.
This will be fixed soon for sure.

@cheenamalhotra
Copy link
Member

Closing as #580 got merged.

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

No branches or pull requests

4 participants