Checking for Null field value

Results 1 to 3 of 3

Thread: Checking for Null field value

  1. #1
    Join Date
    Dec 1969

    Default Checking for Null field value

    I&#039;m trying to check for a null field value before I assign it&#039;s value to a TextBox control. In ASP, I used to use the IsNull() function. This gives a "Name &#039;IsNull&#039; is not declared" error in So, I tried [code language=""]RS("SomeField") is nothing[/code], but it&#039;s not "nothing", it&#039;s an object. So, I tried [code language=""]not RS("DuesPaidDate").IsDBNull[/code]. This gives me an error, "Public member &#039;IsDBNull&#039; on type &#039;DBNull&#039; not found". The only thing that works is this: [code language=""]if "[" & RS("DuesPaidDate").ToString() & "]" &#060;&#062; "[]"[/code]. Surely there&#039;s got to be a better way to do this than that. How do I do this "elegantly"?<BR><BR>Thanks,<BR>Jesse

  2. #2
    Join Date
    Dec 1969

    Default Do it in your SQL statement

    [code language="VB.NET"]SELECT IsNull(SomeField,&#039;&#039;) As SomeField FROM Table[/code]<BR><BR>you are guarenteed a string right off the bat

  3. #3
    Join Date
    Dec 1969

    Default RE: Checking for Null field value

    what I do is something like:<BR> Me.txtPA_DueDateLA.Text = fnIsNull(SQLDataReader("PA_DueDateLA"))<BR><BR><BR >Function fnIsNull(ByVal Val)<BR> If IsDBNull(Val) Then<BR> Return ""<BR> Else<BR> Return Val<BR> End If<BR> End Function

Posting Permissions

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