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.

System.Data.SqlClient clarify SqlDataReader get char

See original GitHub issue

Sql Server doesn’t have an individual char datatype and in desktop .net the SqlDataReader.GetChar is marked as not browsable and implemented as a NotSupportedException. The version in this repository lacks the browsable attribute (in src and ref) and I think it should be re-added.

The documentation for SqlDataReader.GetFieldValue<T> lists char as one of the permitted types but it will not work, there is no metadata support or way to get a char from the database. This means it will always throw an InvalidCastException and I believe it should throw NotSupportedException where T is char to align with GetChar. This would be a behaviour change and need adding to the documentation.

@saurabh500 @AfsanehR @tarikulsabbir

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Wraith2commented, Sep 22, 2020

If you’ve checked and I hid it but didn’t close this issue then it’s closable now.

0reactions
cheenamalhotracommented, Sep 22, 2020

Thanks @Wraith2 for confirming, we’ll close this thread then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SqlDataReader GetChar(int index) method
Because SqlDataReader implements IDataReader , it has a GetChar() method. ... SqlDataReader reader, int columnIndex) { System.Data.SqlTypes.
Read more >
SqlDataReader.GetChars(Int32, Int64, Char ...
Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.
Read more >
SqlDataReader.GetChar(Int32) Method
Gets the value of the specified column as a single character.
Read more >
ADO.NET SqlDataReader in C# with Example
The ADO.NET SqlDataReader class in C# is used to read data from the SQL Server database in the most efficient manner. It reads...
Read more >
ADO.NET Interview Questions And Answers
System.Data.SqlClient, Contains the classes that are used to ... GetChar will return a column value as a character and GetString as a string ......
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