C# Bit problem

J

Jason Huang

Hi,

In my SQLServer 2000 MyDataBase.MyTable, there's one field MyStatus which
datatype is Bit(1).
So the MyStatus in MyTable is either 0 or 1.
Now I have a ComboBox MyCombo in MyForm, and there're two items "Yes" and
"No". Where "Yes" represents 0 in MyTable.MyStatus, and "No" represents 1
in MyTable.MyStatus.
How do update MyStatus from MyCombo? I can't find any conversion in C# to
Bit.
Thanks for help.


Jason
 
L

Lenard Gunda

Hi,

The Bit(1) SQL data type translates to bool in C#. So you can use a bool
which you set to true or false. True will be 1 in the Bit, and false
will be 0.

So for your example, you need a bool, which you set to true if the user
selects "No", and to false, if the user selects "Yes".

Hope that helps,

-Lenard
 

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