|
-
Apr 15th, 2004, 02:13 PM
#1
Thread Starter
Frenzied Member
sending a boolean value to a db [RESOLVED]
when you have a boolean variable, vb sees that as 'true' or 'false', not '0' or '1'. when I send the value to a db field of type 'bit', the process crashes cause it actually receives a string of 'false' (cause I am trying to set the variable to '0' and it gets defaulted to 'false')
I have two options,:
1) use type byte for the variable and use 0's or 1's
2) use type integer and use 0's or 1's and use more resources for the variable size.
I'm trying to use the smallest size possible. In addition to these options, what else can be done?
Last edited by Andy; Apr 19th, 2004 at 08:52 AM.
-
Apr 15th, 2004, 05:52 PM
#2
Member
Set the field type to True/False and use the following code
VB Code:
If BooleanVariable = True Then
IntegerVariable = 1
Else
IntegerVariable = 0
End If
Then when you do your updating query, use the variables to update the True/False field:
VB Code:
UpdateQueryString = "UPDATE DatabaseName SET TrueFalseField = " & IntegerVariable
That will set the value of the field to whatever you want. I have a program that uses true false fields to determine whether an item was received or not, and this method worked for me.
-
Apr 15th, 2004, 06:49 PM
#3
Thread Starter
Frenzied Member
excellent! I'll try that for sure. I know that a byte is 8 bits and an integer is 32 bits. Not that it matters in today's processing world but I'm sure staying concience of resources is important, right?
-
Apr 19th, 2004, 08:52 AM
#4
Thread Starter
Frenzied Member
I am using the byte for now. If anyone has anymore suggestions, I'd be more than happy to try them out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|