Results 1 to 4 of 4

Thread: sending a boolean value to a db [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    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.

  2. #2
    Member
    Join Date
    Mar 2004
    Location
    Miami FL
    Posts
    38
    Set the field type to True/False and use the following code

    VB Code:
    1. If BooleanVariable = True Then
    2.      IntegerVariable = 1
    3. Else
    4.      IntegerVariable = 0
    5. End If

    Then when you do your updating query, use the variables to update the True/False field:

    VB Code:
    1. 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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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
  •  



Click Here to Expand Forum to Full Width