Dataset problem with column named "System"


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.
 
Ad

Advertisements

M

Marc Gravell

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
 
C

Chris Botha

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

Cor Ligthert[MVP]

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
 
Ad

Advertisements

M

Marc Gravell

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;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top