PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

2.0 : DataColumn.DataType

 
 
John A Grandy
Guest
Posts: n/a
 
      17th Feb 2006
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)
:


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      18th Feb 2006
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)
> :
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:53 PM.