'dr' is a 'variable' but is used like a 'method'


I wonder if the quotes were added around those those as a sarcastic ‘emphasis’. Anyway, this is a common error that Visual Studio will toss when Visual Basic programmers are writing C# code. ;) It’s one of those syntax differences between the two languages that takes a few weeks to untrain yourself on. Mine happened to be while using a data reader so I thought I would share the difference for anyone Googling.

VB.Net

Dim buf As String = dr("id")

C#

string buf = dr["id"].ToString();

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.