Results 1 to 6 of 6

Thread: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    64

    Smile In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    Hi Guys,

    In VB.NET is there a

    SQL IsNull(value,valueifNull) or
    Access NZ Type Function

    ie if an object or a string value is null you can give it a default value using a function
    eg
    If IsNull(me.txtname.text,"Blank") = "Blank" Then
    msgbox "Please enter name"
    end if

    Thanks
    Rag

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    Hi. there a sample on how to check sql null.
    VB Code:
    1. con.ConnectionString = constring
    2.         con.Open()
    3.         com.Connection = con
    4.         com.CommandType = CommandType.Text
    5.         com.CommandText = "select codigo from armazem  where codigo  ='" & artigo & "'"
    6.         reader = com.ExecuteReader
    7.         While reader.Read
    8.             If TypeOf reader(0) Is DBNull Then
    9.                 existe = False
    10.             Else
    11.                 existe = True
    12.             End If
    13.         End While
    14.         reader.Close()
    15.         con.Close()
    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    Addicted Member
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    198

    Re: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    If IsDBNull(Obj) Then

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    64

    Re: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    Thanks guys,

    so in .net u have to distinguish between
    a DB null and Null assigned to a VB variable because it hasnt been initiated?

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    Quote Originally Posted by ragstta
    Thanks guys,

    so in .net u have to distinguish between
    a DB null and Null assigned to a VB variable because it hasnt been initiated?
    corect
    VB Code:
    1. if var is nothing then
    "The dark side clouds everything. Impossible to see the future is."

  6. #6
    Addicted Member
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    198

    Re: In VB.NET is there a SQL IsNull(value,valueifNull) or Access NZ Type Function

    You got Nullable, Nothing and DBNull dont know if there are more ;P

    more info
    Last edited by figa; Jan 31st, 2007 at 10:58 AM.

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