473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Handling empty relation to child object

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
Nov 20 '05 #1
4 1012
A trck I always use is this:

x = myInvoice.Client.Name & ""

Hth,
Martin
"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:%2****************@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

Nov 20 '05 #2
Thanks for the reply Martin, but that still throws and exception because
myInvoice.Client is Nothing.
Or am I missing something?

"Martin" <am*******@nospam.hotmail.com> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...
A trck I always use is this:

x = myInvoice.Client.Name & ""

Hth,
Martin
"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:%2****************@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


Nov 20 '05 #3
No, you're not missing anything, I did.

I missed the 'Client' in between the dots.

In this case, sorry but I don't know any other way than to test if client =
nothing...


"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:Od**************@TK2MSFTNGP12.phx.gbl...
Thanks for the reply Martin, but that still throws and exception because
myInvoice.Client is Nothing.
Or am I missing something?

"Martin" <am*******@nospam.hotmail.com> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...
A trck I always use is this:

x = myInvoice.Client.Name & ""

Hth,
Martin
"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:%2****************@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



Nov 20 '05 #4
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" <an*****@nospam.dbasplus.com> wrote in message
news:%2****************@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

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Frame | last post by:
I'm looking for tutorials or articles considering HTML Frames and how to handle them with Javascript. E.g. samples how Frames can exchange information, can a Frame instruct other Frame to update...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
1
by: krishna | last post by:
Hi, I have doubt in MDI forms genarally we will set formname.MdiParent=me in the mdi form if it is child but my doubt is when i open another child in the child form of the mdi form it is...
0
by: Ambica Jain | last post by:
I have a data grid called Files, which has some columns like FileName, Col1, Col2, ... , Col8. Then i have a combobox which allows user to select from Col1 to Col8 and based on this selection, i...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
1
by: Ginger Estherskip | last post by:
I'm setting up a dataset using the GUI to have a Parent Data Table and a few Child Data Tables. I then have a form that uses that dataset, and I can fill the appropriate datatables et. al., but...
5
by: Valery | last post by:
In the following XML: <?xml version="1.0" encoding="utf-8" ?> <Plcy service="ILiability" boId ="LifePolicy, 1"> <Prem service="IPremium" boId ="RegularPremium, 1"></Prem> <L1...
5
by: Rafe | last post by:
Hi, I've been thinking in circles about these aspects of Pythonic design and I'm curious what everyone else is doing and thinks. There are 3 issues here: 1) 'Declaring' attributes - I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.