Hi John,
You have a trailing space after Int32.
Anyway it is better to do it this way:
dc.DataType = typeof(int);
--
Miha Markic [MVP C#]
RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:O4yqIZ$(E-Mail Removed)...
>I took this code right out of the VS05 docs , placed it in a method in a
>separate class , from the page instantiate that class and call the method
>.... error thrown:
>
> using System.Data;
>
> DataColumn dc = new DataColumn("Int32Col");
>
> dc.DataType = System.Type.GetType("System.Int32 ");
>
> Throws error:
>
> System.ArgumentException was unhandled by user code
> Message="Column requires a valid DataType."
> Source="System.Data"
> StackTrace:
> at System.Data.DataColumn.set_DataType(Type value)
> at TasksDataTier.ReadTasks(DataTable& dt) in
> c:\code\2.0\gui\code\App_Code\TasksDataTier.cs:line 164
> at TaskManagerWithCode.ReadTasks() in
> c:\code\2.0\gui\code\TaskManagerWithCode.aspx.cs:line 31
> at TaskManagerWithCode.Page_Load(Object sender, EventArgs e) in
> c:\code\2.0\gui\code\TaskManagerWithCode.aspx.cs:line 20
> at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
> Object o, Object t, EventArgs e)
> at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
> sender, EventArgs e)
> at System.Web.UI.Control.OnLoad(EventArgs e)
> at System.Web.UI.Control.LoadRecursive()
> at System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> :
>
>