473,397 Members | 2,033 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,397 software developers and data experts.

XML "ini"FIle - How to Detect a Missing Value

I've got the basics of an XML ini file working. I.E. I can stash away
and retrieve user preferences. (Code below.) But how do I handle a
new preference? Say I have A and B. And then I invent C. The first
time the new version with C is run the XML file will not have a value
for C. How do I detect that case? Somewhere I got the impression
that I could use IsNull, but I was unable to find an example which I
could apply to my code. My attempt to use IsNull gives a runtime
error:

An unhandled exception of type 'System.MissingMemberException'
occurred in microsoft.visualbasic.dll

Additional information: Public member 'IsNull' on type 'String' not
found.

Here's my code (The runtine error happens in the btnLoad Sub).
Imports System
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Dim AppDir As String = Directory.GetCurrentDirectory()

#Region " Windows Form Designer generated code "

#End Region

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim ds As New DataSet("Settings") 'dataset
Dim dt As New DataTable("Textbox") 'table

dt.Columns.Add("xxx_filename", GetType(String)) 'add
columns
dt.Columns.Add("bbb_filename", GetType(String))
dt.Columns.Add("ignore_NOINS", GetType(Boolean))
dt.Columns.Add("log_filename", GetType(String))

dt.Rows.Add(dt.NewRow) 'add a row to table
ds.Tables.Add(dt) 'add table to the dataset

dt.Rows(0)("xxx_filename") = tbxXxxFile.Text 'set
values
dt.Rows(0)("bbb_filename") = tbxBbbFile.Text
dt.Rows(0)("ignore_NOINS") = chkbxIgnoreNOINS.Checked
dt.Rows(0)("log_filename") = tbxLogFile.Text

ds.WriteXml(AppDir & "\testxml.xml") 'write XML file

dt = Nothing
ds = Nothing

End Sub

Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLoad.Click

Dim ds As New DataSet
Dim dt As DataTable

ds.ReadXml(AppDir & "\testxml.xml") '= ds.Tables(0)

If ds.Tables("Textbox").Rows(0)("xxx_filename").IsNul l Then
MsgBox("Whoops, xxx_filename IsNull")
End If

tbxXxxFile.Text = ds.Tables("Textbox").Rows(0)("xxx_filename")
tbxBbbFile.Text = ds.Tables("Textbox").Rows(0)("bbb_filename")
chkbxIgnoreNOINS.Checked =
ds.Tables("Textbox").Rows(0)("ignore_NOINS")
tbxLogFile.Text = ds.Tables("Textbox").Rows(0)("log_filename")

dt = Nothing
ds = Nothing

End Sub
End Class

Nov 21 '05 #1
2 1906
Hi,

ds.Tables("Textbox").Rows(0).IsNull ("xxx_filename")
Ken
----------------
"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:he********************************@4ax.com...
I've got the basics of an XML ini file working. I.E. I can stash away
and retrieve user preferences. (Code below.) But how do I handle a
new preference? Say I have A and B. And then I invent C. The first
time the new version with C is run the XML file will not have a value
for C. How do I detect that case? Somewhere I got the impression
that I could use IsNull, but I was unable to find an example which I
could apply to my code. My attempt to use IsNull gives a runtime
error:

An unhandled exception of type 'System.MissingMemberException'
occurred in microsoft.visualbasic.dll

Additional information: Public member 'IsNull' on type 'String' not
found.

Here's my code (The runtine error happens in the btnLoad Sub).
Imports System
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Dim AppDir As String = Directory.GetCurrentDirectory()

#Region " Windows Form Designer generated code "

#End Region

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim ds As New DataSet("Settings") 'dataset
Dim dt As New DataTable("Textbox") 'table

dt.Columns.Add("xxx_filename", GetType(String)) 'add
columns
dt.Columns.Add("bbb_filename", GetType(String))
dt.Columns.Add("ignore_NOINS", GetType(Boolean))
dt.Columns.Add("log_filename", GetType(String))

dt.Rows.Add(dt.NewRow) 'add a row to table
ds.Tables.Add(dt) 'add table to the dataset

dt.Rows(0)("xxx_filename") = tbxXxxFile.Text 'set
values
dt.Rows(0)("bbb_filename") = tbxBbbFile.Text
dt.Rows(0)("ignore_NOINS") = chkbxIgnoreNOINS.Checked
dt.Rows(0)("log_filename") = tbxLogFile.Text

ds.WriteXml(AppDir & "\testxml.xml") 'write XML file

dt = Nothing
ds = Nothing

End Sub

Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLoad.Click

Dim ds As New DataSet
Dim dt As DataTable

ds.ReadXml(AppDir & "\testxml.xml") '= ds.Tables(0)

If ds.Tables("Textbox").Rows(0)("xxx_filename").IsNul l Then
MsgBox("Whoops, xxx_filename IsNull")
End If

tbxXxxFile.Text = ds.Tables("Textbox").Rows(0)("xxx_filename")
tbxBbbFile.Text = ds.Tables("Textbox").Rows(0)("bbb_filename")
chkbxIgnoreNOINS.Checked =
ds.Tables("Textbox").Rows(0)("ignore_NOINS")
tbxLogFile.Text = ds.Tables("Textbox").Rows(0)("log_filename")

dt = Nothing
ds = Nothing

End Sub
End Class
Nov 21 '05 #2
Thank you Ken, but it did not seem to work. I got ...

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: Column 'xxx_filename' does not belong to table
Textbox.

I made the change you gave me. Ran the app, put some data in my text
boxes and hit my Save button. Closed the app. Edited the xml file to
remove the xxx_filename data. Ran the app and hit the Load button.

Here's the complete code with your change ...

Imports System
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Dim AppDir As String = Directory.GetCurrentDirectory()

#Region " Windows Form Designer generated code "
#End Region

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim ds As New DataSet("Settings") 'dataset
Dim dt As New DataTable("Textbox") 'table

dt.Columns.Add("xxx_filename", GetType(String)) 'add
columns
dt.Columns.Add("bbb_filename", GetType(String))
dt.Columns.Add("ignore_NOINS", GetType(Boolean))
dt.Columns.Add("log_filename", GetType(String))

dt.Rows.Add(dt.NewRow) 'add a row
to table
ds.Tables.Add(dt) 'add table
to the dataset

dt.Rows(0)("xxx_filename") = tbxXxxFile.Text 'set
values
dt.Rows(0)("bbb_filename") = tbxBbbFile.Text
dt.Rows(0)("ignore_NOINS") = chkbxIgnoreNOINS.Checked
dt.Rows(0)("log_filename") = tbxLogFile.Text

ds.WriteXml(AppDir & "\testxml.xml") 'write
XML file

dt = Nothing
ds = Nothing

End Sub

Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLoad.Click

Dim ds As New DataSet
Dim dt As DataTable

ds.ReadXml(AppDir & "\testxml.xml") '= ds.Tables(0)

If ds.Tables("Textbox").Rows(0).IsNull("xxx_filename" ) Then
MsgBox("Whoops, xxx_filename IsNull")
End If

tbxXxxFile.Text = ds.Tables("Textbox").Rows(0)("xxx_filename")
tbxBbbFile.Text = ds.Tables("Textbox").Rows(0)("bbb_filename")
chkbxIgnoreNOINS.Checked =
ds.Tables("Textbox").Rows(0)("ignore_NOINS")
tbxLogFile.Text = ds.Tables("Textbox").Rows(0)("log_filename")

dt = Nothing
ds = Nothing

End Sub
End Class


On Thu, 3 Mar 2005 23:10:07 -0500, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote:
Hi,

ds.Tables("Textbox").Rows(0).IsNull ("xxx_filename")
Ken
----------------
"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:he********************************@4ax.com.. .
I've got the basics of an XML ini file working. I.E. I can stash away
and retrieve user preferences. (Code below.) But how do I handle a
new preference? Say I have A and B. And then I invent C. The first
time the new version with C is run the XML file will not have a value
for C. How do I detect that case? Somewhere I got the impression
that I could use IsNull, but I was unable to find an example which I
could apply to my code. My attempt to use IsNull gives a runtime
error:

An unhandled exception of type 'System.MissingMemberException'
occurred in microsoft.visualbasic.dll

Additional information: Public member 'IsNull' on type 'String' not
found.

Here's my code (The runtine error happens in the btnLoad Sub).
Imports System
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Dim AppDir As String = Directory.GetCurrentDirectory()

#Region " Windows Form Designer generated code "

#End Region

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim ds As New DataSet("Settings") 'dataset
Dim dt As New DataTable("Textbox") 'table

dt.Columns.Add("xxx_filename", GetType(String)) 'add
columns
dt.Columns.Add("bbb_filename", GetType(String))
dt.Columns.Add("ignore_NOINS", GetType(Boolean))
dt.Columns.Add("log_filename", GetType(String))

dt.Rows.Add(dt.NewRow) 'add a row to table
ds.Tables.Add(dt) 'add table to the dataset

dt.Rows(0)("xxx_filename") = tbxXxxFile.Text 'set
values
dt.Rows(0)("bbb_filename") = tbxBbbFile.Text
dt.Rows(0)("ignore_NOINS") = chkbxIgnoreNOINS.Checked
dt.Rows(0)("log_filename") = tbxLogFile.Text

ds.WriteXml(AppDir & "\testxml.xml") 'write XML file

dt = Nothing
ds = Nothing

End Sub

Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLoad.Click

Dim ds As New DataSet
Dim dt As DataTable

ds.ReadXml(AppDir & "\testxml.xml") '= ds.Tables(0)

If ds.Tables("Textbox").Rows(0)("xxx_filename").IsNul l Then
MsgBox("Whoops, xxx_filename IsNull")
End If

tbxXxxFile.Text = ds.Tables("Textbox").Rows(0)("xxx_filename")
tbxBbbFile.Text = ds.Tables("Textbox").Rows(0)("bbb_filename")
chkbxIgnoreNOINS.Checked =
ds.Tables("Textbox").Rows(0)("ignore_NOINS")
tbxLogFile.Text = ds.Tables("Textbox").Rows(0)("log_filename")

dt = Nothing
ds = Nothing

End Sub
End Class


Nov 21 '05 #3

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

Similar topics

0
by: Doug | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 14 Message-ID: <9DxFc.23833$bs4.23734@newsread3.news.atl.earthlink.net> Date: Sat, 03 Jul 2004...
1
by: Alan Little | last post by:
Has anyone ever figured out the problem with this? I have sendmail_from set in my php.ini, and I also in this case have a custom From: header, but I still get this message. Here's the relevant...
5
by: lvcha.gouqizi | last post by:
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372...
8
by: Eric Bragas | last post by:
What is this? <img src="{$ ImagesDir}/photo.gif"> I KNOW what an HTML image tag looks like. But what do you call that in the file source? Is it like a virtual directory in IIS? It's some type...
10
by: Maximus | last post by:
I need to make a loop that echoes some text after "x" time of seconds. Any help?
4
by: chris.huh | last post by:
This may not be the best place to put this but i have set up apache as a testing server on my local machine. Whenever i try to use a formmail.php script i downloaded is always come sup saying that...
8
by: Seth Darr | last post by:
I'm working on migrating an Classic ASP/VB6 COM application from an NT Server with IIS<6 to an virtual machine running Windows Server 2003 and IIS 6. I've worked through most of the obvious...
0
by: Michael Fay in SB | last post by:
A month ago I posted: "I built my application with Access 2003 and made a distribution using the Microsoft Office Access 2003 Developer Extensions. (I also install Jet 8 as a follow-on action at...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.