checkbox oracle char type

M

mrstrong

Gday,

I have a checkbox on my windows forms that I need to set based on a
value in a dataset which is populated by an odp data adapter via a web
service.
The value in the oracle database is of type char(1) with possible values 'Y'
or 'N' (there are no boolean values in oracle).

The code (c#) that I currently have that is being called from the form's
load procedure to set the checkbox is as follows:

if (dsMyDataSet.Tables[<table>].Rows[0][<field>]== 'Y')

chkBox.Checked = true;

else

chkBox.Checked = false;



However there are two issues that I hope you might be able to point me
in the right direction with:

1. How do you do comparisons for type char? (I get this message:
Operator
'==' cannot be applied to operands of type 'object' and 'char')

2. I am not sure how to reference the current row in the dataset

If this is not the right forum please point me in the right direction.

Regards,

Peter
 
P

Patrice

#1. Rows[0][<field>] is an object. I would cast it to a char to do the
comparison
#2. A DataTable doesn't have a current row. What is the context ? Do you
have several rows returned ? You could iterate yourself the rows collection
or in the context of dataBinding you can use Container.DataItem to get the
the currently binded row).
 

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

Top