Re: Handling empty relation to child object

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: OpticTygre (optictygre_at_adelphia.net)
Date: 07/23/04


Date: Thu, 22 Jul 2004 21:38:03 -0400

What if you just did

Try
    x = myInvoice.Client.Name
Catch
    x = ""
End Try

It's essentially the same thing, but you won't have to check for Client =
Nothing. I'm not sure if this is faster than your way, though.

-J

"Andrew" <andrewt@nospam.dbasplus.com> wrote in message
news:%23pT5EM7bEHA.3864@TK2MSFTNGP10.phx.gbl...
> In a Typed Dataset, is there a way on the xs:keyref tag that I can specify
> how to handle null child objects?
>
> For example, if I have an Invoice table, where a ClientID key is used to
> create a reference to a Clients Table by it's ID Column. On the Clients
> table I have a Name element.
> In the calling code I do :
> x = myInvoice.Reference
> x = myInvoice.Amount
> x = myInvoice.Rate
> x = myInvoice.Client.Name
> this will throw an error if, for whatever reason, the Client does not
exist.
> How can I get it to return an empty string instead of having to do :
>
> If Not myInvoice.Client = Nothing Then
> x = myInvoice.Client.Name
> else
> x = ""
> End If
>
>



Relevant Pages

  • Re: malloc()/realloc() - have I got this right?
    ... For some reason that is beound me you elected to ignore CBF's next ... he prefers this to be done by the calling code. ... The client has to ... or go home and simply say "the salmon was unavailable" ...
    (comp.lang.c)
  • Re: malloc()/realloc() - have I got this right?
    ... For some reason that is beound me you elected to ignore CBF's next ... he prefers this to be done by the calling code. ... The client has to ... or go home and simply say "the salmon was unavailable" ...
    (comp.lang.c)
  • Re: malloc()/realloc() - have I got this right?
    ... For some reason that is beound me you elected to ignore CBF's next ... he prefers this to be done by the calling code. ... The client has to ... or go home and simply say "the salmon was unavailable" ...
    (comp.lang.c)
  • Re: malloc()/realloc() - have I got this right?
    ... For some reason that is beound me you elected to ignore CBF's next ... The debate was whether the caller or the callee should disambiguate ... this to be done by the calling code. ... The client has to ...
    (comp.lang.c)
  • Re: Buffer size when receiving data through a socket?
    ... tried sending an empty string from the server back to the client, and as expected it exited the loop and closed the client, which doesn't make sense to me, since an empty string could be perfectly valid return data. ...
    (comp.lang.python)