Home All Groups Group Topic Archive Search About

Check to see DataColumn DataType is Boolean?

Author
3 May 2006 8:33 PM
Jay Balapa
Hello,

Iam trying to do the following-

if(myColumn.DataType==typeof(bool))
{
}

I get the error "Operator == cannot be applied to operands type and object
and bool."

Is there a workaround?

Thanks.
jay

Author
3 May 2006 8:59 PM
Sericinus hunter
Jay Balapa wrote:
> Hello,
>
> Iam trying to do the following-
>
> if(myColumn.DataType==typeof(bool))
> {
> }
>
> I get the error "Operator == cannot be applied to operands type and object
> and bool."
>
> Is there a workaround?

    Try Type.GetType("System.Boolean") instead of typeof(bool).
Author
3 May 2006 9:12 PM
Jay Balapa
Hi Hunter,

Error states that I cannot use "==" operator period when comparing Boolean.

I have tried what you suggested and it does not work.

jay



Show quote
"Sericinus hunter" <serh***@flash.net> wrote in message
news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com...
> Jay Balapa wrote:
>> Hello,
>>
>> Iam trying to do the following-
>>
>> if(myColumn.DataType==typeof(bool))
>> {
>> }
>>
>> I get the error "Operator == cannot be applied to operands type and
>> object and bool."
>>
>> Is there a workaround?
>
>    Try Type.GetType("System.Boolean") instead of typeof(bool).
Author
3 May 2006 9:24 PM
Sericinus hunter
Jay Balapa wrote:
> Hi Hunter,
>
> Error states that I cannot use "==" operator period when comparing Boolean.
>
> I have tried what you suggested and it does not work.
>
> jay

    Strange. Works for me with .Net 1.1

Show quote
> "Sericinus hunter" <serh***@flash.net> wrote in message
> news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com...
>> Jay Balapa wrote:
>>> Hello,
>>>
>>> Iam trying to do the following-
>>>
>>> if(myColumn.DataType==typeof(bool))
>>> {
>>> }
>>>
>>> I get the error "Operator == cannot be applied to operands type and
>>> object and bool."
>>>
>>> Is there a workaround?
>>    Try Type.GetType("System.Boolean") instead of typeof(bool).
>
>
Author
3 May 2006 9:40 PM
Jay Balapa
Iam using 2.0.


Show quote
"Sericinus hunter" <serh***@flash.net> wrote in message
news:7c96g.782$zR3.530@newssvr33.news.prodigy.com...
> Jay Balapa wrote:
>> Hi Hunter,
>>
>> Error states that I cannot use "==" operator period when comparing
>> Boolean.
>>
>> I have tried what you suggested and it does not work.
>>
>> jay
>
>    Strange. Works for me with .Net 1.1
>
>> "Sericinus hunter" <serh***@flash.net> wrote in message
>> news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com...
>>> Jay Balapa wrote:
>>>> Hello,
>>>>
>>>> Iam trying to do the following-
>>>>
>>>> if(myColumn.DataType==typeof(bool))
>>>> {
>>>> }
>>>>
>>>> I get the error "Operator == cannot be applied to operands type and
>>>> object and bool."
>>>>
>>>> Is there a workaround?
>>>    Try Type.GetType("System.Boolean") instead of typeof(bool).
>>
Author
4 May 2006 5:37 PM
Cor Ligthert [MVP]
Jay,

Can you show the code as you did that,
This should in my opinion be the same in 1.x as in 2.0


Cor

Show quote
"Jay Balapa" <jbal***@hotmail.com> schreef in bericht
news:uOpWKpvbGHA.3908@TK2MSFTNGP02.phx.gbl...
> Iam using 2.0.
>
>
> "Sericinus hunter" <serh***@flash.net> wrote in message
> news:7c96g.782$zR3.530@newssvr33.news.prodigy.com...
>> Jay Balapa wrote:
>>> Hi Hunter,
>>>
>>> Error states that I cannot use "==" operator period when comparing
>>> Boolean.
>>>
>>> I have tried what you suggested and it does not work.
>>>
>>> jay
>>
>>    Strange. Works for me with .Net 1.1
>>
>>> "Sericinus hunter" <serh***@flash.net> wrote in message
>>> news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com...
>>>> Jay Balapa wrote:
>>>>> Hello,
>>>>>
>>>>> Iam trying to do the following-
>>>>>
>>>>> if(myColumn.DataType==typeof(bool))
>>>>> {
>>>>> }
>>>>>
>>>>> I get the error "Operator == cannot be applied to operands type and
>>>>> object and bool."
>>>>>
>>>>> Is there a workaround?
>>>>    Try Type.GetType("System.Boolean") instead of typeof(bool).
>>>
>
Author
3 May 2006 10:37 PM
MSDN
This works,  .NET - FW2.0

DataColumn myColumn = new
DataColumn("name",System.Type.GetType("System.Boolean"));

if (myColumn.DataType == typeof(bool))

{

if (myColumn.DataType == typeof(Boolean))

{

xxx = "okay";

}

}



Show quote
"Jay Balapa" <jbal***@hotmail.com> wrote in message
news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl...
> Hello,
>
> Iam trying to do the following-
>
> if(myColumn.DataType==typeof(bool))
> {
> }
>
> I get the error "Operator == cannot be applied to operands type and object
> and bool."
>
> Is there a workaround?
>
> Thanks.
> jay
>
>
>
>
Author
4 May 2006 8:02 AM
Miha Markic [MVP C#]
Hi Jay,

That code should work.
What is the myColumn type exactly?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Jay Balapa" <jbal***@hotmail.com> wrote in message
news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl...
> Hello,
>
> Iam trying to do the following-
>
> if(myColumn.DataType==typeof(bool))
> {
> }
>
> I get the error "Operator == cannot be applied to operands type and object
> and bool."
>
> Is there a workaround?
>
> Thanks.
> jay
>
>
>
>
Author
4 May 2006 2:29 PM
Jay Balapa
Hi Miha,

Thanks for replying.

myColumn is just an iterator for a row.

foreach (DataColumn myColumn from myTable.Columns)

Thanks.
jay

Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:ugSGME1bGHA.4108@TK2MSFTNGP03.phx.gbl...
> Hi Jay,
>
> That code should work.
> What is the myColumn type exactly?
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Jay Balapa" <jbal***@hotmail.com> wrote in message
> news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl...
>> Hello,
>>
>> Iam trying to do the following-
>>
>> if(myColumn.DataType==typeof(bool))
>> {
>> }
>>
>> I get the error "Operator == cannot be applied to operands type and
>> object and bool."
>>
>> Is there a workaround?
>>
>> Thanks.
>> jay
>>
>>
>>
>>
>
>
Author
4 May 2006 4:52 PM
Miha Markic [MVP C#]
Can you create a simple sample that reproduces the problem?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Jay Balapa" <jbal***@hotmail.com> wrote in message
news:e29qFd4bGHA.3348@TK2MSFTNGP03.phx.gbl...
> Hi Miha,
>
> Thanks for replying.
>
> myColumn is just an iterator for a row.
>
> foreach (DataColumn myColumn from myTable.Columns)
>
> Thanks.
> jay
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:ugSGME1bGHA.4108@TK2MSFTNGP03.phx.gbl...
>> Hi Jay,
>>
>> That code should work.
>> What is the myColumn type exactly?
>>
>> --
>> Miha Markic [MVP C#]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>> "Jay Balapa" <jbal***@hotmail.com> wrote in message
>> news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl...
>>> Hello,
>>>
>>> Iam trying to do the following-
>>>
>>> if(myColumn.DataType==typeof(bool))
>>> {
>>> }
>>>
>>> I get the error "Operator == cannot be applied to operands type and
>>> object and bool."
>>>
>>> Is there a workaround?
>>>
>>> Thanks.
>>> jay
>>>
>>>
>>>
>>>
>>
>>
>
>

AddThis Social Bookmark Button