accessing secondary datasource from vb.net

D

DSI_FC

I'm getting frustrated with InfoPath and the Visual Studio SDK

I can't get the selectsingelnode structure right.

I have a from with 2 primary text fields, one of them is named ProjectID.
(my:projectID)
I have a secondary dataset and the structure is: myFields, dataFields,
d:OrProjectI What I basicly need to do is the copy the info from the dataset
field: ProjectID to the text field my:projectID.

I have tried all kinds ways to write the xpath , but I always get an empty
object back.

This is what I have tried:

Dim x1 = e.Source.selectSingleNode("//my:projectID")
Dim x2 = e.Source.selectSingleNode _

("//dfs:myFields//dfs:datafields//dfs:OrProject[@ProjectID]")

x1.text = x2.text

x2 = Nothing

x1 works fine .. I can do x1.text = "test" and it gets set

I have tried:

Dim myDoc As IXMLDOMDocument3 =
thisXDocument.DataObjects("OrProject").DOM

myDoc.setProperty("SelectionNamespaces", _

'"xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'
xmlns:d='http://schemas.microsoft.com/office/infopath/2003/ado/dataFields'")

Dim textnode As IXMLDOMNode = myDoc.selectSingleNode("@ProjectID")
x1.text = textnode.text

crashes on x1.text = ...

What am I doing wrong ?
 
S

Steve from next to BadgerLand

I have a similar question, to whomever answers the first
question. I am using a simple XML Doc with a single
node "Position" as my secondary data source. It does not
have a namespace associated with it. How can I still use
the GETDOM method?
-----Original Message-----
I'm getting frustrated with InfoPath and the Visual Studio SDK

I can't get the selectsingelnode structure right.

I have a from with 2 primary text fields, one of them is named ProjectID.
(my:projectID)
I have a secondary dataset and the structure is: myFields, dataFields,
d:OrProjectI What I basicly need to do is the copy the info from the dataset
field: ProjectID to the text field my:projectID.

I have tried all kinds ways to write the xpath , but I always get an empty
object back.

This is what I have tried:

Dim x1 = e.Source.selectSingleNode ("//my:projectID")
Dim x2 = e.Source.selectSingleNode _

("//dfs:myFields//dfs:datafields//dfs:OrProject [@ProjectID]")

x1.text = x2.text

x2 = Nothing

x1 works fine .. I can do x1.text = "test" and it gets set

I have tried:

Dim myDoc As IXMLDOMDocument3 =
thisXDocument.DataObjects("OrProject").DOM

myDoc.setProperty("SelectionNamespaces", _

'"xmlns:dfs='http://schemas.microsoft.com/office/infopath /2003/dataFormSolution'
3/ado/dataFields'")

Dim textnode As IXMLDOMNode = myDoc.selectSingleNode("@ProjectID")
x1.text = textnode.text

crashes on x1.text = ...

What am I doing wrong ?




.
 
S

steve

I solved my problem, but am interested in the answer to
the answer to the original post

Thank You

-----Original Message-----
I have a similar question, to whomever answers the first
question. I am using a simple XML Doc with a single
node "Position" as my secondary data source. It does not
have a namespace associated with it. How can I still use
the GETDOM method?
-----Original Message-----
I'm getting frustrated with InfoPath and the Visual Studio SDK

I can't get the selectsingelnode structure right.

I have a from with 2 primary text fields, one of them
is
named ProjectID.
(my:projectID)
I have a secondary dataset and the structure is: myFields, dataFields,
d:OrProjectI What I basicly need to do is the copy the info from the dataset
field: ProjectID to the text field my:projectID.

I have tried all kinds ways to write the xpath , but I always get an empty
object back.

This is what I have tried:

Dim x1 = e.Source.selectSingleNode ("//my:projectID")
Dim x2 = e.Source.selectSingleNode _

("//dfs:myFields//dfs:datafields//dfs:OrProject [@ProjectID]")

x1.text = x2.text

x2 = Nothing

x1 works fine .. I can do x1.text = "test" and it gets set

I have tried:

Dim myDoc As IXMLDOMDocument3 =
thisXDocument.DataObjects("OrProject").DOM

myDoc.setProperty("SelectionNamespaces", _

'"xmlns:dfs='http://schemas.microsoft.com/office/infopat
h
/2003/dataFormSolution'
0
3/ado/dataFields'")

Dim textnode As IXMLDOMNode = myDoc.selectSingleNode("@ProjectID")
x1.text = textnode.text

crashes on x1.text = ...

What am I doing wrong ?




.
.
 
F

FlemmingC

This is my own brute-force solution, but you have to know the name of the
table so it's not generic:

In this example I'm there is only 1 record in the datasource ("tablename")

Dim oNodes As IXMLDOMNodeList
Dim oNode As IXMLDOMNode

oNodes = thisXDocument.GetDOM("tablename").selectNodes("//*")
For i As Integer = 0 To oNodes.length - 1
oNode = oNodes.nextNode
If Not (oNode Is Nothing) Then
If oNode.attributes.length > 0 Then
For i2 As Integer = 0 To oNode.attributes.length - 1
Select Case oNode.attributes.Item(i2).nodeName
Case "Field1"
thisXDocument.DOM.selectSingleNode("//my:field1").text = _
oNode.attributes.Item(i2).text
Case "Field2"
thisXDocument.DOM.selectSingleNode("//my:field2").text = _
oNode.attributes.Item(i2).text
Case "Field3"
thisXDocument.DOM.selectSingleNode("//my:field3").text = _
oNode.attributes.Item(i2).text
End Select
Next
End If
End If
Next
End Sub


I would like to make a more generic sub, where I firts find the
datasource(s) used and then fill out fields in the form.

Can anyone tell me how to find the names of the datasources (tablenames) ?

/Flemming
 

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