Referencing a node using selectSingleNode....

E

Enterprise Andy

Hi,

I am trying to populate a field on my form, which is linked to an SQL
back-end database, but need assistance in referencing the field.

I am trying to use:
XDocument.DOM.selectSingleNode("/my:myfields/my:DataFields/my:TblStaffDetails/my:userName").text

to reference the field, which is called UserName and is part of the
d:TblStaffDetails group, which in turn is a member of the dataFields groups,
which in turn is a member of the myFields group.

The code above causes an error saying '... is null or not an object'. How do
I correctly reference the field so I can populate it onLoad.

Many thanks in advance for you help!
 
M

MatsonPP

I am going to assume that since you used the "my:" namespace in your
example, that you linked to the database by doing the "New from data
connection" when you created your form. So, if I follow your example in
reference to field and foler names, then the way to reference your
field is as such:

string str =
XDocument.DOM.selectSingleNode("//d:TblStaffDetails/@userName").text;

I hope that works,
Ciao,
Matt
 
E

Enterprise Andy

Thanks for the reply,

I have tried that and I still get and error complaining '... is null or not
an object'. Any ideas why?
 

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