DataTable columns collection

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
 
E

Eliyahu Goldin

Dan,

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

mercercreek

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
 

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

Staff online

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top