Underscore ("_") prefix added to my Column Name

  • Thread starter Thread starter r0bb1e
  • Start date Start date
R

r0bb1e

I manually created a DataTable in a Typed DataSet using the DataSet designer
in VS 2008 Pro. One of the Column names is "IN". When referencing this
table in VB.Net 2008, the IntelliSense did not show the column "IN" but it
did show a column "_IN'. If I tried to reference this column in code using
"tablenameRow.IN" I got the build error: "'IN' is not a member of
'app.DataSet.tableRow". If I reference it with "tablenameRow._IN" then I
don't get the build error. I have several other 2-letter-capitalized column
names in this table such as: "'LT', 'PI' and 'MA'". These other column names
show up in intellisense and can be referenced without the "_" prefix.

Can someone tell me what's going on?

Thanks
 
T thought of that, so for a test I created a Column named "FROM'. This did
not cause a column named "_FROM" to be created. And referencing
"tablenameRow.From" caused no build errors. Furthermore, Intellisense showed
the column "From" in the list of properties/columns for the DataTable Row.
(Although it didn't show up as all capitals in Intellisense and when I put
"tablenameRow.FROM" in my code, Visual Studio changed it to
"tablenameRow.From".

So why does the system treat "FROM" different from "IN"? They're both SQL
reserverd words.

--
Robert Scarborough
Integrated Visual Systems


Miha Markic said:
IN is a sql keyword....
 
IN is a reserved word in VB.Net. If you look at the underlying column name
constant, you'll see that it is still named "IN".

Note: This doesn't happen in C#, only in VB. Also note that wrapping IN
inside of [] allows what you want in normal classes, however the generation
tool doesn't know to do this.

VB

Public Property [IN]() As String
Public Property_IN() As String

C#

public string IN {get;set;}



r0bb1e said:
T thought of that, so for a test I created a Column named "FROM'. This did
not cause a column named "_FROM" to be created. And referencing
"tablenameRow.From" caused no build errors. Furthermore, Intellisense
showed
the column "From" in the list of properties/columns for the DataTable Row.
(Although it didn't show up as all capitals in Intellisense and when I put
"tablenameRow.FROM" in my code, Visual Studio changed it to
"tablenameRow.From".

So why does the system treat "FROM" different from "IN"? They're both SQL
reserverd words.

--
Robert Scarborough
Integrated Visual Systems


Miha Markic said:
IN is a sql keyword....

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

r0bb1e said:
I manually created a DataTable in a Typed DataSet using the DataSet
designer
in VS 2008 Pro. One of the Column names is "IN". When referencing
this
table in VB.Net 2008, the IntelliSense did not show the column "IN" but
it
did show a column "_IN'. If I tried to reference this column in code
using
"tablenameRow.IN" I got the build error: "'IN' is not a member of
'app.DataSet.tableRow". If I reference it with "tablenameRow._IN" then
I
don't get the build error. I have several other 2-letter-capitalized
column
names in this table such as: "'LT', 'PI' and 'MA'". These other column
names
show up in intellisense and can be referenced without the "_" prefix.

Can someone tell me what's going on?

Thanks
 
Back
Top