Problems with DataSet and column names -
12-11-2007
, 07:40 AM
Hi,
I have following problem - I have a table in sql database that
contains column named System
I created dataset in vs2005 application and dragged this table form
server explorer, problem is I get errors in auto generated code
because same name of System namespace and System property:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public string System {
get {
try {
return ((string)
(this[this.tableID.SystemColumn]));
}
catch (System.InvalidCastException e) {
throw new
System.Data.StrongTypingException("The value for column \'System\' in
table \'ID\' is DBNull.", e);
}
}
set {
this[this.tableID.SystemColumn] = value;
}
}
And all references in code returns error:
System.DBNull.Value
System.Convert.DBNull
System.Data.ConnectionState.Open
Of course manually editing this file, adding using System solves
problem, but I need to do it every time I make slightest change in
dataset, because auto generator is overriding this file after I make
any changes.
And for different reasons I cannot change name of this column neither
in sql nor in dataset. Is there any way to prevent generator to
override this file all the time, or any way to solve the problems with
duplicate names ? |