I am trying to create a DataColumn with Name and DataType parameters.
As I understand from the documentation, one of the overloads supports
creation of a column with these two parameters. When I tried
folllowing, however I get error saying

'int' denotes a 'class' where a 'variable' was expected

code
-------
DataColumn dc = new DataColumn("Name", System.Int32)

or

DataColumn dc = new DataColumn("Name",
System.Type.GetType(System.Int32))

or

MyTable.Columns.Add("Name", System.Int32)

ERROR:
-------
'int' denotes a 'class' where a 'variable' was expected


I am using .NET Framework 1.1 in Visual Studio.NET environment. Is
this a bug or am I doing something wrong

Re: DataColumn.Add bug? DataType parameter cannot be added by William

William
Tue Feb 03 22:51:35 CST 2004

Sachin:

I only have 1.2 Framework in front of me, but if I take your code and wrap
the GetType("System.Int32") in quotes, it works fine. Similarly, if I get
the type....
int32 myType;
Type t = int32.GetType();
and use t in the constructor, it's works as well.
"Sachin Kulkarni" <sachink@dstc.edu.au> wrote in message
news:ae15592f.0402031943.588caaae@posting.google.com...
> I am trying to create a DataColumn with Name and DataType parameters.
> As I understand from the documentation, one of the overloads supports
> creation of a column with these two parameters. When I tried
> folllowing, however I get error saying
>
> 'int' denotes a 'class' where a 'variable' was expected
>
> code
> -------
> DataColumn dc = new DataColumn("Name", System.Int32)
>
> or
>
> DataColumn dc = new DataColumn("Name",
> System.Type.GetType(System.Int32))
>
> or
>
> MyTable.Columns.Add("Name", System.Int32)
>
> ERROR:
> -------
> 'int' denotes a 'class' where a 'variable' was expected
>
>
> I am using .NET Framework 1.1 in Visual Studio.NET environment. Is
> this a bug or am I doing something wrong



Re: DataColumn.Add bug? DataType parameter cannot be added by sachink

sachink
Tue Feb 03 23:31:05 CST 2004

Ok

I can't do Int32.GetType(
Columns.Add("Name", System.Int32) still doesn't wor

but the good news is

Columns.Add("Name", System.Type.GetType("System.Int32")) DOES work !

My have had tried this option as well but only without Namespace - GetType("Int32") which didn't work.

Thanks a lo

----- William Ryan eMVP wrote: ----

Sachin

I only have 1.2 Framework in front of me, but if I take your code and wra
the GetType("System.Int32") in quotes, it works fine. Similarly, if I ge
the type...
int32 myType
Type t = int32.GetType()
and use t in the constructor, it's works as well
"Sachin Kulkarni" <sachink@dstc.edu.au> wrote in messag
news:ae15592f.0402031943.588caaae@posting.google.com..
> 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
>> cod
> ------
> DataColumn dc = new DataColumn("Name", System.Int32
>> o
>> 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




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


Re: DataColumn.Add bug? DataType parameter cannot be added by anonymous

anonymous
Tue Feb 03 23:36:05 CST 2004

Hello Ryan

Is Int32.GetType() supported ?

How about the typeof operator eg. typeof(System.Int32) ?

Anjoe

----- William Ryan eMVP wrote: -----

Sachin:

I only have 1.2 Framework in front of me, but if I take your code and wrap
the GetType("System.Int32") in quotes, it works fine. Similarly, if I get
the type....
int32 myType;
Type t = int32.GetType();
and use t in the constructor, it's works as well.
"Sachin Kulkarni" <sachink@dstc.edu.au> wrote in message
news:ae15592f.0402031943.588caaae@posting.google.com...
> I am trying to create a DataColumn with Name and DataType parameters.
> As I understand from the documentation, one of the overloads supports
> creation of a column with these two parameters. When I tried
> folllowing, however I get error saying
>> 'int' denotes a 'class' where a 'variable' was expected
>> code
> -------
> DataColumn dc = new DataColumn("Name", System.Int32)
>> or
>> DataColumn dc = new DataColumn("Name",
> System.Type.GetType(System.Int32))
>> or
>> MyTable.Columns.Add("Name", System.Int32)
>> ERROR:
> -------
> 'int' denotes a 'class' where a 'variable' was expected
>>> I am using .NET Framework 1.1 in Visual Studio.NET environment. Is
> this a bug or am I doing something wrong