using double data with root.selectsinglenode - InfoPath Dev
in

InfoPath Dev

Now you can find InfoPathDev on YouTube and Twitter!
Find Qdabra on Facebook

using double data with root.selectsinglenode

Last post 10-17-2008 03:13 AM by MichalBojko. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-09-2008 03:00 PM

    using double data with root.selectsinglenode

     i have three fields (s_john, t_john, Cost) on a infopath form. i defined data type as Decimal(double) for all of the fields. I am trying to run the code below when user clicks a button.

     XPathNavigator root = MainDataSource.CreateNavigator();
                
                double JohnSalary = root.SelectSingleNode("my:myFields/my:Salary/my:s_john", NamespaceManager).Value;
                double JohnWorkHours = root.SelectSingleNode("my:myFields/my:TotalHours/my:t_john", NamespaceManager).Value;

                double asd = JohnSalary * JohnWorkHours;
                root.SelectSingleNode("my:myFields/my:Cost", NamespaceManager).SetValue(asd);

     

    However i am getting the errors below:

    Error    1    Cannot implicitly convert type 'string' to 'double'    C:\Documents and Settings\eyilmaz\My Documents\InfoPath Projects\Template15\FormCode.cs    40    33    Template1

    Error    2    Cannot implicitly convert type 'string' to 'double'    C:\Documents and Settings\eyilmaz\My Documents\InfoPath Projects\Template15\FormCode.cs    41    36    Template1

    Error    3    Cannot convert method group 'SetValue' to non-delegate type 'double'. Did you intend to invoke the method?    C:\Documents and Settings\eyilmaz\My Documents\InfoPath Projects\Template15\FormCode.cs    44    13    Template1

     What am i missing here? 

    Thank You.

  • 01-10-2008 06:22 AM In reply to

    Re: using double data with root.selectsinglenode

     OK. i changed the code like this.

     XPathNavigator root = MainDataSource.CreateNavigator();

                double JohnSalary = root.SelectSingleNode("my:myFields/my:Salary/my:s_john", NamespaceManager).ValueAsDouble;
              
                double JohnWorkHours = root.SelectSingleNode("my:myFields/my:TotalHours/my:t_john", NamespaceManager).ValueAsDouble;
                
                double asd = JohnSalary * JohnWorkHours;
                root.SelectSingleNode("my:myFields/my:Cost", NamespaceManager).SetTypedValue(asd);

     

    Now i am getting some security error. 

    System.Security.SecurityException was unhandled by user code
      Message="Request failed."
      Source="Microsoft.Office.InfoPath.Client.Internal.Host"
      StackTrace:
           at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)
           at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()
           at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
           at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
           at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
           at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
           at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
           at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)
           at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
           at Template1.FormCode.CTRL7_5_Clicked(Object sender, ClickedEventArgs e)
           at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
           at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
     

  • 01-10-2008 09:14 AM In reply to

    Re: using double data with root.selectsinglenode

     interesting but i started getting this security error after i installed Microsoft Visual Web Developer 2008 Express Edition. i do not know why this application causes such a error like that.

  • 01-10-2008 09:47 PM In reply to

    Re: using double data with root.selectsinglenode

    Hi Viperay,

    MSXML should not have changed, so hard to think that was a problem. Maybe something going on with Internet Explorer. Did the version of that change? I don't know what the problem is here. Sorry for not being more specific.

    Patrick Halstead
    InfoPath MVP
  • 01-11-2008 08:53 AM In reply to

    Re: using double data with root.selectsinglenode

     Really interesting. I uninstall web express also i reinstall infopath still i am getting same security error. 2 week ago i designed some forms and people use it now without any problem.When i try to use same form i am getting security error again. This must be a bug or something. Also i tried to write many different codes, as soon as i run the form it gives me that security error and it shows the very first code line for that error.

     Here is some ss

    http://img211.imageshack.us/img211/3347/infole3.jpg

    http://img186.imageshack.us/img186/8741/info2pz9.jpg

  • 01-11-2008 08:59 AM In reply to

    Re: using double data with root.selectsinglenode

    viperay, I believe the problem you are experiencing may be related to you having installed VS 2008 or more precisely .NET runtime 3.5. I think there is a bug there which breaks InfoPath solutions. There should be a hotfix for it eventually but for now your best bet is to make the solution full-trust. Let me know if this temporary workaround fixes your problems.

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-11-2008 09:02 AM In reply to

    Re: using double data with root.selectsinglenode

     Yes i thought about it. That is why i uninstall .net 3.5 but still same error. I will work on it, if i solve i ll post it, but it seems that the end of this is gonna be reinstalling windows.

    Here some ss

    http://img211.imageshack.us/img211/3347/infole3.jpg

    http://img186.imageshack.us/img186/8741/info2pz9.jpg

  • 10-17-2008 03:13 AM In reply to

    Re: using double data with root.selectsinglenode

    problem is in form security. Set it to Ful Trust and it should work.

     

    regards

    Mike

Page 1 of 1 (8 items)
Copyright © 2003-2010 Qdabra Software. All rights reserved.
View our Terms of Use.