Null value in database, what is it in code?

Results 1 to 2 of 2

Thread: Null value in database, what is it in code?

  1. #1
    Join Date
    Dec 1969

    Default Null value in database, what is it in code?

    Hi,<BR><BR>I have a text field in an Access 2000 table. Set to...<BR><BR>Required No<BR>Allow Zero Length Yes<BR><BR>Now when I use .AddNew/.Update to add a record to the table is it added as a Null or a Zero Length String? The access help tells me that in access if I do this in access...<BR><BR>Presses ENTER - Null<BR>Presses SPACEBAR - Null<BR>Enters a zero-length string Null - Zero-length string <BR><BR>...those are their respective results...but if I create a new record or update a record from and asp page not putting a value in the field, is it added as a null or a zero lenght string? I can&#039;t find a way to tell in access, though I am sure there is a properties tab somewhere!<BR><BR>Anyway, I am concerned because in my code I want to test the so...<BR><BR>If objTesting("TextField") &#060;&#062; "" Then...<BR><BR>Now should I test the field as "" or as Null like soo...<BR><BR>If objTesting("TextField") &#060;&#062; Null Then<BR><BR>Right now both tests work fine...<BR><BR>When I do some testing...<BR><BR>If objTesting("TextField") = Null Then<BR> Response.Write "WOO"<BR>End If<BR><BR>Woo is not written with both Null and "" in the above. I have also created the record as a null and "" when putting the record in and tested all the above but still no Woo.<BR><BR>But I know "" and Null are not the same thing.<BR><BR>Anyone? Are there some standard rules anyone can point me to?<BR><BR>TIA<BR><BR>

  2. #2
    Joel N Guest

    Default RE: Null value in database, what is it in code?

    Straight from Microsoft&#039;s VBScript Documentation:<BR><BR><BR>IsNull Function<BR>Returns a Boolean value that indicates whether an expression contains no valid data ( Null).<BR><BR>IsNull(expression)<BR><BR>The expression argument can be any expression.<BR><BR>Remarks<BR>IsNull returns True if expression is Null, that is, it contains no valid data; otherwise, IsNull returns False. If expression consists of more than one variable, Null in any constituent variable causes True to be returned for the entire expression.<BR><BR>The Null value indicates that the variable contains no valid data. Null is not the same as Empty, which indicates that a variable has not yet been initialized. It is also not the same as a zero-length string (""), which is sometimes referred to as a null string.<BR><BR>Caution Use the IsNull function to determine whether an expression contains a Null value. Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var &#060;&#062; Null, are always False. This is because any expression containing a Null is itself Null, and therefore, False.<BR><BR>The following example uses the IsNull function to determine whether a variable contains a Null: <BR><BR>Dim MyVar, MyCheck<BR>MyCheck = IsNull(MyVar) &#039; Returns False.<BR>MyVar = Null &#039; Assign Null.<BR>MyCheck = IsNull(MyVar) &#039; Returns True.<BR>MyVar = Empty &#039; Assign Empty.<BR>MyCheck = IsNull(MyVar) &#039; Returns False.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts