Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2004, 02:29 AM
Registered User
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default xml in vb.net

From the book "professional vb.net 2003" I am creating the code as per the instructions but get an error message:

"Object reference not set to an instance of an object"

The problem is highlighted where it is asterixed in the code below:

        prescriptions = serialize.Deserialize(dehydrated)

        Dim prescription As WXClientPrescription
        For Each prescription In prescriptions.prescriptions
            Console.Out.WriteLine("{0},{1},{2}", _
                    prescription.dentistName, _
                    prescription.medicationID, _
                    prescription.quantity)

        Next**


It is taken from chapter 10 p307.


 
Old November 10th, 2004, 06:48 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't think it will be throwing an exception where you have marked with an asterisk. Much more likely is the previous line where you are referring to three different properties of the prescription object. These three properties need to be checked for whether the property exists or not; something like

Code:
Dim dentistName as String, medicationID, quantity as Integer
If IsDbNull(prescription.dentistName) Then _
    dentistName = "" Else _
    dentistName = prescription.dentistName
If IsDbNull(medicationID) Then _
    medicationID = 0 Else _
    medicationID = prescription.medicationID
If IsDbNull(prescription.quantity) Then _
    quantity = 0 Else _
    quantity = prescription.quantity
Console.Out.WriteLine("{0},{1},{2}", _
                    dentistName, _
                    medicationID, _
                    quantity)





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
Parse XML doc using VB.NET into ASP.NET page kwilliams Classic ASP XML 17 November 11th, 2005 10:42 AM
Beginning VB.NET XML wdyson All Other Wrox Books 0 January 31st, 2005 10:37 AM
Using VB.NET and XML offline BruceHamilton VS.NET 2002/2003 1 April 9th, 2004 09:26 AM
XML to XML through an XSLT (VB.NET) dimondwoof XSLT 1 June 25th, 2003 12:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.