Skip to content
Advertisement

SQLDataReader does not show value of column with double colon in field name

A Select query works fine when I enter it in SQL Server Management Studio on SQL Server:

The column name is “00:00” – it has a double colon. When I try to get the value from this column in a VB.net function with the help of a SqlDataReader, the result is always an error:

Column does not exist

I have tried to put the column name in all variations of brackets, quotation marks, without brackets at all etc. I still can not retrieve the value in the table.

My VB.NET code:

How do have to quote/escape the column name correctly so that it works in a SqlDataReader?

Advertisement

Answer

This:

should be

The name is 00:00. Not [00:00]. This is a delimited identifier and the [ and ] are only present in TSQL, and enable the parser to tell where the name begins and ends when the name doesn’t follow the rules for regular identifiers.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement