DataTable columns collection

  • Thread starter Thread starter mercercreek
  • Start date Start date
M

mercercreek

An attempt to create a stand-alone DataTable returns unexpected errors.

Using this bit of code - lifted from MSDN:

DataTable dt = new DataTable("Customers");

I get the following error: "No overload for method 'DataTable' takes
'1' arguments"

So, I remove the parameter and the compiler makes it as far as:

DataColumn dc = dt.Columns.Add("CustID", typeof(Int32));

At that point I get this error: "DataTable' does not contain a
definition for 'Columns'"

Sure enough, intellisense shows no "Columns" collection for the
DataTable class.
This appears contrary to documentation. Am I missing something?

Thanks
Dan
 
Dan,

Are you sure you don't override the DataTable class somewhere in your code?
Try full class name System.Data.DataTable.
 
Eliyahu said:
Dan,

Are you sure you don't override the DataTable class somewhere in your code?
Try full class name System.Data.DataTable.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


mercercreek said:
An attempt to create a stand-alone DataTable returns unexpected errors.

Using this bit of code - lifted from MSDN:

DataTable dt = new DataTable("Customers");

I get the following error: "No overload for method 'DataTable' takes
'1' arguments"

So, I remove the parameter and the compiler makes it as far as:

DataColumn dc = dt.Columns.Add("CustID", typeof(Int32));

At that point I get this error: "DataTable' does not contain a
definition for 'Columns'"

Sure enough, intellisense shows no "Columns" collection for the
DataTable class.
This appears contrary to documentation. Am I missing something?

Thanks
Dan
 
Back
Top