Changing datatype property of a node element

B

BethA

I'm struggling with trying to get some Booleans in my schema to behave
correctly. It seems that when I declare the node like this:

Dim oOnDSNNode As IXMLDOMElement =
thisXDocument.DOM.selectSingleNode("my:myFields/my:OnDSN")

the datatype of oOnDSNNode is set to DBNull instead of boolean (OnDSN in my
schema is set as a boolean).

I've tried to find a way to make sure the datatype property of oOnDSNNode is
boolean, but I'm stuck!

Can someone help please? Thanks!

Beth A.
 
F

Franck Dauché

Hi Beth,

I am afraid datatype won't help you much. If you really need to check the
nature of your node, the only way that I know of is to load you schema as a
separate document from your code and to check through that. This is not
straight forward, if you can avoid it...
Why don't you pick a naming convention, such as all boolean nodes starts by
"b"

Hope that it helps.

Regards,

Franck Dauché
 
B

BethA

The nodes in question are boolean in the schema. The problem comes up when I
declare a node in VB.net and assign it to this node (while the boolean is
empty), the declared node has a null datatype and I get an error that it
can't be converted to boolean. I'm going to try it again, first giving those
fields a default value.

Beth A.
 
B

BethA

I really meant that I would required the field to not be blank. That didn't
make a difference. I still get an error at the line:

oOnDSNNode.nodeTypedValue = mDSN

where mDSN is a boolean variable - I get the error:

Cast from type 'DBNull' to type 'Boolean' is not valid.

Any ideas?

Thanks,
Beth
 
F

Franck Dauché

How are you assigning the value? .text = "true"?

Regards,

Franck Dauché
 
B

BethA

I have a boolean variable mDSN that I want to assign to the nodetypedvalue
property of the node:

oOnDSNNode.nodeTypedValue = mDSN

That's when I get the error. The node oOnDSNNode seems to be assigned to the
correct thing.

I think the problem may have started when I changed the original field from
boolean to text and then back to boolean. (I was having a problem with the
boolean field getting a -1 assigned for true.) Now I need to get this working!

Thanks,
Beth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top