RE: DataColumn.Add bug? DataType parameter cannot be added by anonymous
anonymous
Tue Feb 03 23:36:05 CST 2004
Hello Sachin
The Following Overloads are provided by the DataColumn Constructor.
1. Initializes a new instance of a DataColumn class
[C#] public DataColumn()
2. Inititalizes a new instance of the DataColumn class using the specified column name
[C#] public DataColumn(string)
3. Inititalizes a new instance of the DataColumn class using the specified column name and data type
[C#] public DataColumn(string, Type)
4. Initializes a new instance of the DataColumn class using the specified name, data type, and expression
[C#] public DataColumn(string, Type, string)
5. Initializes a new instance of the DataColumn class using the specified name, data type, expression, and value that determines whether the column is an attribute
[C#] public DataColumn(string, Type, string, MappingType)
Please note the type of the DataColumn is always passed as an object of type System.Type, Hence it is essential that you use either
1. System.GetType("Fully-Qualified-Name-Of-Type") eg. System.GetType("System.Int32"
2. typeof(TypeName) eg. typeof(System.Int32
to create a System.Type object for the desired type and pass the same to the constructor.
----- Sachin Kulkarni wrote: ----
I am trying to create a DataColumn with Name and DataType parameters
As I understand from the documentation, one of the overloads support
creation of a column with these two parameters. When I trie
folllowing, however I get error sayin
'int' denotes a 'class' where a 'variable' was expecte
code
------
DataColumn dc = new DataColumn("Name", System.Int32
or
DataColumn dc = new DataColumn("Name"
System.Type.GetType(System.Int32)
o
MyTable.Columns.Add("Name", System.Int32
ERROR:
------
'int' denotes a 'class' where a 'variable' was expecte
I am using .NET Framework 1.1 in Visual Studio.NET environment. I
this a bug or am I doing something wron