Dataset problem with column named "System"

  • Thread starter Thread starter Chris Botha
  • Start date Start date
C

Chris Botha

The customer has a database with a column in a table named "System". I've
been using this method for years now - create a dataset (an .xsd file) for
the table. With a column named "System" in the dataset, it gives a
substantial number of compile errors.

To simplify the problem, add a Dataset with one table and one column called
"System" - below follows how it can be done:
Right click on the solution, click "Add", click "New Item" and then
"DataSet" and DataSet1 is OK for the name.
On the design sheet of DataSet1.xsd, right click. click "Add" and click
"DataTable".
Right click on the DataTable and click "Add" and click "Column".
Rename the column from "Column1" to "System".
Build the project = compile errors.
Note that renaming the column to "[System]" rather than "System" does not
work either.
 
You are best-off avoiding things called "System"; unfortunately, it
means that anything with explicit namespace resolution (i.e. what the
designer spits out) will break, unless you start using aliases, or the
global prefix. Seriously - just cheat and call it SystemFlag or
similar; it just isn't worth the pain...

Marc
 
Hi Mark, thanks. Alias or global prefix sounds good - as this is just one
column, if you know how please let me know?
 
Chris,

In my opinion is Marc his advice very good, spare you the time, with this
word you have the change that it will happen again later.

Cor
 
Demo below, but this is *not* a good idea; it will keep biting you,
and could make IDE functions like the forms designer very unreliable.

using SomeAlias = System;

class SystemDemo
{
bool System { get { return true; } }
void AliasDemo()
{
SomeAlias.Net.TransportType type =
SomeAlias.Net.TransportType.Tcp;
}
void GlobalDemo()
{
global::System.Net.TransportType type =
global::System.Net.TransportType.Tcp;
}
}
 
Back
Top