SQL bit column default value

B

Bob Day

Using vs.2003, SQL native

1) I presume that the SQL bit data type is the equivalent of Boolean data
type in VS 2003. I have used it that way, and it works fine.

2) Given above, using Server Explorer, Design Table, what can I put in the
default field for FALSE for a bit data type column? The IDE accepts ('0')
and also (0) as OK (and fails on things like ('False') as I would expect)..
But when you create a new row and save it to the data source, it fails,
indicating you cannot write a null to that field (it is set up as
non-nullable). I use defaults as a way of avoiding nulls, but cannot figure
out the default for a bit filed.

Please give me the answer specifically for the Default Field in the Design
Table dialog box, what the exact entry would be. These fields often use
different
formats than SQL.

What works?

Bob Day
 
B

Bob Graham

(0) always works for me, if you enter 0 by itself it's changed to (0) next
time you open design view.

I get no errors creating new rows without specifying values for these
fields.

Bob
 
B

Bob Day

If doesn't work for me. If you use Sever Explorer, and display data, add a
row manually, it does work just fine.

If you add a row via DataAdapter, it fails. Is there some setting in
DataAdapter I am missing?

I will review my code to see.

Bob Day
 
B

Bob Graham

If I don't want my code to set the field true, I don't even mention it in my
sqladapter's command text. If it is in the command text I set it to 0 if I
don't want it to be true. The point is, don't mention it, you're fine, do
mention it--> make sure to supply a value.

Bob
 

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