question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
karinazhoucommented, May 26, 2020

@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.

1reaction
karinazhoucommented, 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,

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How can I retrieve a list of parameters from a stored ...
GetSchema () method to return all the stored procedures associated with a database, and then subsequently all the parameter names and types ...
Read more >
Create Your Own SQL Compare Utility Using GetSchema()
Learn how to use the GetSchema() method on the DbConnection class to retrieve tables, views, columns, index, stored procedures, ...
Read more >
SqlConnection.GetSchema Method (System.Data.SqlClient)
Returns schema information for the data source of this SqlConnection using the specified string for the schema name and the specified string array...
Read more >
4.9. Getting Stored Procedure Parameter Information at ...
Problem. You want to get information about the parameters used by a stored procedure at runtime.
Read more >
Connection (Java Platform SE 8 )
A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found