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.
I am using System.Data.SqlClient 4.8.1 from nuget with project configured as .Net Framework 4.7.
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
/cc @cheenamalhotra
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,
HI @karinazhou ,
Yes, I think "ProcedureParameters" is missing in SqlClientMetaDataCollectionNames.cs
Furthermore, the predefined string "Parameters" is invalid since it will cause exception.
@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.
Closing as #580 got merged.
Most helpful comment
@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.