VB question

S

steve

I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)

Imports System.Xml
Imports System.Xml.XPath

Dim myNav As XPathNavigator = MainDataSource.CreateNavigator()

which doesn't compile because MainDataSource is undefined, which makes
sense, since it's not.
My question: what is MainDataSource? Where does it come from?

thanks!



code is from site:

http://enterprise-solutions.swits.n...m-sharepoint-calendar-infopath&c=infopath2007

XPathNavigator root = MainDataSource.CreateNavigator();

// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;

XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();

// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);

// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);

// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));

// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));

// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();
 
S

S.Y.M. Wong-A-Ton

What version of InfoPath are you using? MainDataSource in InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
 
S

steve

Thanks for taking the time to answer my post.

Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.

thanks again,

steve



What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
---
S.Y.M. Wong-A-Ton



I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?

code is from site:

XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -

- Show quoted text -
 
S

S.Y.M. Wong-A-Ton

No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.n...-calendar-infopath-2003-script&c=infopath2003).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
---
S.Y.M. Wong-A-Ton


Thanks for taking the time to answer my post.

Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.

thanks again,

steve



What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
---
S.Y.M. Wong-A-Ton



I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?

code is from site:

XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -

- Show quoted text -
 
S

steve

No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
---
S.Y.M. Wong-A-Ton



Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
---
S.Y.M. Wong-A-Ton
:
I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?
thanks!
code is from site:
http://enterprise-solutions.swits.net/infopath2007/article.php?t=prog...
XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:

batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title

the error is:

System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent
pEvent)




MainCalendar is my CAML data connection.

It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title

Looks ok to me - but it doesn't work...

if anybody has any ideas that would be great.

steve





Dim title As String
Dim startDate As String
Dim endDate As String

startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text

Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate

' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate

' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()
 
S

S.Y.M. Wong-A-Ton

Try declaring batch as IXMLDOMDocument and see if that helps.

I also see that you changed the names of the attributes in the batch XML?
The adding of the event might fail, but we'll cross that bridge when we get
there.
---
S.Y.M. Wong-A-Ton


No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
---
S.Y.M. Wong-A-Ton



Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,

On Feb 24, 5:24 pm, S.Y.M. Wong-A-Ton
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
:
I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?

code is from site:

XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:

batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title

the error is:

System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent
pEvent)




MainCalendar is my CAML data connection.

It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title

Looks ok to me - but it doesn't work...

if anybody has any ideas that would be great.

steve





Dim title As String
Dim startDate As String
Dim endDate As String

startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text

Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate

' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate

' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()
 
S

steve

wow! YES, defining it as IXMLDOMDocument got me past that problem.

I changed the names to 'end' and 'begin' because those are the names
on the Events list i have in SharePoint.
they should match, right?

I"m down to the last line - the submit -
thisXDocument.DataAdapters("SubmitToCalendar").Submit() - gets the
following error (i'm running it in Preview mode)


System.MethodAccessException
Attempt to access the method failed.
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
MethodBase method, ParameterInfo[] Parameters, Object[] args, Type
objType, IReflect objIReflect)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack, Boolean IgnoreReturn)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 264
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper

Try declaring batch as IXMLDOMDocument and see if that helps.

I also see that you changed the names of the attributes in the batch XML?
The adding of the event might fail, but we'll cross that bridge when we get
there.
---
S.Y.M. Wong-A-Ton



No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since morepeople
have been struggling with the conversion from 2007 to 2003.
---
S.Y.M. Wong-A-Ton
:
Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,
steve
On Feb 24, 5:24 pm, S.Y.M. Wong-A-Ton
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's thesame in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
---
S.Y.M. Wong-A-Ton
:
I need to translate the C# (below) to VB.(this is related to mylonger
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?
thanks!
code is from site:
http://enterprise-solutions.swits.net/infopath2007/article.php?t=prog...
XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
the error is:
System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper­.OnLoad(DocReturnEvent
pEvent)
MainCalendar is my CAML data connection.
It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title
Looks ok to me - but it doesn't work...
if anybody has any ideas that would be great.

Dim title As String
Dim startDate As String
Dim endDate As String
startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text
Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate
' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate
' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()- Hide quoted text -

- Show quoted text -
 
S

S.Y.M. Wong-A-Ton

The error is telling me that .NET cannot invoke the Submit method. Perhaps
the method cannot be accessed/seen on the object.

Try declaring the DataAdapter explicitly, like in:

Dim adpt As WebServiceAdapter2 =
thisXDocument.DataAdapters("SubmitToCalendar")

and then call the Submit, like in:

adpt.Submit()


Regarding the name changes: When you create a list, SharePoint uses a list
schema. And the names defined in the schema differ from what you specify at
the front-end. But let me know whether your name changes work, since I'm no
SharePoint expert.
---
S.Y.M. Wong-A-Ton


wow! YES, defining it as IXMLDOMDocument got me past that problem.

I changed the names to 'end' and 'begin' because those are the names
on the Events list i have in SharePoint.
they should match, right?

I"m down to the last line - the submit -
thisXDocument.DataAdapters("SubmitToCalendar").Submit() - gets the
following error (i'm running it in Preview mode)


System.MethodAccessException
Attempt to access the method failed.
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
MethodBase method, ParameterInfo[] Parameters, Object[] args, Type
objType, IReflect objIReflect)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack, Boolean IgnoreReturn)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 264
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper

Try declaring batch as IXMLDOMDocument and see if that helps.

I also see that you changed the names of the attributes in the batch XML?
The adding of the event might fail, but we'll cross that bridge when we get
there.
---
S.Y.M. Wong-A-Ton



On Feb 25, 1:19 am, S.Y.M. Wong-A-Ton
No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
"(e-mail address removed)" wrote:
Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,

On Feb 24, 5:24 pm, S.Y.M. Wong-A-Ton
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
:
I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?

code is from site:

XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
the error is:
System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper­.OnLoad(DocReturnEvent
pEvent)
MainCalendar is my CAML data connection.
It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title
Looks ok to me - but it doesn't work...
if anybody has any ideas that would be great.

Dim title As String
Dim startDate As String
Dim endDate As String
startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text
Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate
' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate
' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()- Hide quoted text -

- Show quoted text -
 
S

steve

The error is telling me that .NET cannot invoke the Submit method. Perhaps
the method cannot be accessed/seen on the object.

Try declaring the DataAdapter explicitly, like in:

Dim adpt As WebServiceAdapter2 =
thisXDocument.DataAdapters("SubmitToCalendar")

and then call the Submit, like in:

adpt.Submit()

Regarding the name changes: When you create a list, SharePoint uses a list
schema. And the names defined in the schema differ from what you specify at
the front-end. But let me know whether your name changes work, since I'm no
SharePoint expert.
---
S.Y.M. Wong-A-Ton



wow! YES, defining it as IXMLDOMDocument got me past that problem.
I changed the names to 'end' and 'begin' because those are the names
on the Events list i have in SharePoint.
they should match, right?
I"m down to the last line - the submit -
thisXDocument.DataAdapters("SubmitToCalendar").Submit() - gets the
following error (i'm running it in Preview mode)
System.MethodAccessException
Attempt to access the method failed.
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
MethodBase method, ParameterInfo[] Parameters, Object[] args, Type
objType, IReflect objIReflect)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack, Boolean IgnoreReturn)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 264
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper
Try declaring batch as IXMLDOMDocument and see if that helps.
I also see that you changed the names of the attributes in the batch XML?
The adding of the event might fail, but we'll cross that bridge when we get
there.
---
S.Y.M. Wong-A-Ton
:
On Feb 25, 1:19 am, S.Y.M. Wong-A-Ton
No problem. If it is of any help, I just wrote a JScript/VBScriptversion of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article shouldgive you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
---
S.Y.M. Wong-A-Ton
:
Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm lookingfor
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,
steve
On Feb 24, 5:24 pm, S.Y.M. Wong-A-Ton
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So youneed to use
thisXDocument.DOM if you're using InfoPath 2003. I think it'sthe same in
both C# and VB (I do not usually write VB.NET code, so do notknow for sure).
---
S.Y.M. Wong-A-Ton
:
I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding thefollowing
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?
thanks!
code is from site:
http://enterprise-solutions.swits.net/infopath2007/article.php?t=prog...
XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update thecalendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
the error is:
System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) inC:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper­­.OnLoad(DocReturnEvent
pEvent)
MainCalendar is my CAML data connection.
It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title
Looks ok to me - but it doesn't work...
if anybody has any ideas that would be great.
steve
Dim title As String
Dim startDate As String
Dim endDate As String
startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text
Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate
' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate
' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Success! Declaring the data adapter did the trick. I also had to
change the names of the variables
as you suggested - i understand it now. Thanks so much for the help on
this - never would have gotten
it to work otherwise. really helped me out.

In case someone out there needs to do the same thing, here's the
complete VB.NET code:

steve

'
' VB.NET code to automatically create an entry in a
SharePoint Event List
'
'
Dim title As String
Dim startDate As String
Dim endDate As String

startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text

Dim batch As IXMLDOMDocument

' MainCalendar is the Recieve Data Connection w/ the CAML file
connected

batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "title text"
' Set the title
batch.selectSingleNode("Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='EventDate']").text = startDate

' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='EndDate']").text = endDate

' Submit the item details to the web service to update the
calendar -
' SubmitToCalender is a Data Connnection with the web
service defined to it
'
Dim adpt As WebServiceAdapter2 =
thisXDocument.DataAdapters("SubmitToCalendar")
adpt.Submit()
 
S

S.Y.M. Wong-A-Ton

Glad to hear you finally got it to work! And glad I could help.
---
S.Y.M. Wong-A-Ton


The error is telling me that .NET cannot invoke the Submit method. Perhaps
the method cannot be accessed/seen on the object.

Try declaring the DataAdapter explicitly, like in:

Dim adpt As WebServiceAdapter2 =
thisXDocument.DataAdapters("SubmitToCalendar")

and then call the Submit, like in:

adpt.Submit()

Regarding the name changes: When you create a list, SharePoint uses a list
schema. And the names defined in the schema differ from what you specify at
the front-end. But let me know whether your name changes work, since I'm no
SharePoint expert.
---
S.Y.M. Wong-A-Ton



wow! YES, defining it as IXMLDOMDocument got me past that problem.
I changed the names to 'end' and 'begin' because those are the names
on the Events list i have in SharePoint.
they should match, right?
I"m down to the last line - the submit -
thisXDocument.DataAdapters("SubmitToCalendar").Submit() - gets the
following error (i'm running it in Preview mode)
System.MethodAccessException
Attempt to access the method failed.
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
MethodBase method, ParameterInfo[] Parameters, Object[] args, Type
objType, IReflect objIReflect)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack, Boolean IgnoreReturn)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 264
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper
On Feb 25, 2:16 pm, S.Y.M. Wong-A-Ton
Try declaring batch as IXMLDOMDocument and see if that helps.
I also see that you changed the names of the attributes in the batch XML?
The adding of the event might fail, but we'll cross that bridge when we get
there.
:
On Feb 25, 1:19 am, S.Y.M. Wong-A-Ton
No problem. If it is of any help, I just wrote a JScript/VBScript version of
the article for SharePoint 2003 and InfoPath 2003
(http://enterprise-solutions.swits.net/infopath2003/article.php?t=prog...).
I cannot write articles for all the "flavors" of code, so I skipped writing
one for the .NET version of InfoPath 2003, but the article should give you an
idea of how to go about things when using SharePoint 2003, since more people
have been struggling with the conversion from 2007 to 2003.
"(e-mail address removed)" wrote:
Thanks for taking the time to answer my post.
Yes! I'm using 2003, so that explains the mystery! I'm looking for
something that doesn't exist.
No wonder i couldn't find it. So i guess my next quest is to figure
out how to use "DOM" in this situation.
that helps a lot. at least now i have a clue.
thanks again,

On Feb 24, 5:24 pm, S.Y.M. Wong-A-Ton
What version of InfoPath are you using?MainDataSourcein InfoPath 2007 is
the same as DOM in the old InfoPath 2003 object model. So you need to use
thisXDocument.DOM if you're using InfoPath 2003. I think it's the same in
both C# and VB (I do not usually write VB.NET code, so do not know for sure).
:
I need to translate the C# (below) to VB.(this is related to my longer
post from Friday).
So far i can't get past the first line. I tried adding the following
to the OnLoad event of my project:
(i also added these imports)
Imports System.Xml
Imports System.Xml.XPath
Dim myNav As XPathNavigator =MainDataSource.CreateNavigator()
which doesn't compile becauseMainDataSourceis undefined, which makes
sense, since it's not.
My question: what isMainDataSource? Where does it come from?

code is from site:

XPathNavigator root =MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
thanks again - that helped, i think i'm close now ..... I took a shot
at translating to VB.NET (below) - it compiles now, but i get a
runtime error:
on this line:
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
the error is:
System.MissingMemberException
Public member 'selectSingleNode' on type 'DOMDocument50Wrapper' not
found.
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at Absences_Request.Absences_Request.OnLoad(DocReturnEvent e) in C:
\my_data\Visual Studio Projects\Absences Request\FormCode.vb:line 253
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper­­.OnLoad(DocReturnEvent
pEvent)
MainCalendar is my CAML data connection.
It seems like my the XPath statement is wrong in this statement: /
Batch/Method/Field[@Name='Title']").text = title
Looks ok to me - but it doesn't work...
if anybody has any ideas that would be great.

Dim title As String
Dim startDate As String
Dim endDate As String
startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text
Dim batch
batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "testing - ignore"
' Set the title
batch.selectSingleNode("/Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='Begin']").text = startDate
' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='End']").text = endDate
' Submit the item details to the web service to update the
calendar
thisXDocument.DataAdapters("SubmitToCalendar").Submit()- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Success! Declaring the data adapter did the trick. I also had to
change the names of the variables
as you suggested - i understand it now. Thanks so much for the help on
this - never would have gotten
it to work otherwise. really helped me out.

In case someone out there needs to do the same thing, here's the
complete VB.NET code:

steve

'
' VB.NET code to automatically create an entry in a
SharePoint Event List
'
'
Dim title As String
Dim startDate As String
Dim endDate As String

startDate = thisXDocument.DOM.selectSingleNode("//
my:startDate").text
endDate = thisXDocument.DOM.selectSingleNode("//
my:returnDate").text

Dim batch As IXMLDOMDocument

' MainCalendar is the Recieve Data Connection w/ the CAML file
connected

batch = thisXDocument.DataObjects("MainCalendar").DOM
title = "title text"
' Set the title
batch.selectSingleNode("Batch/Method/
Field[@Name='Title']").text = title
' Set the start date
batch.selectSingleNode("/Batch/Method/
Field[@Name='EventDate']").text = startDate

' Set the end date
batch.selectSingleNode("/Batch/Method/
Field[@Name='EndDate']").text = endDate

' Submit the item details to the web service to update the
calendar -
' SubmitToCalender is a Data Connnection with the web
service defined to it
'
Dim adpt As WebServiceAdapter2 =
thisXDocument.DataAdapters("SubmitToCalendar")
adpt.Submit()
 

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