Code behind for button to update to a SQL table - InfoPath Dev
in

InfoPath Dev

Code behind for button to update to a SQL table

Last post 03-19-2010 08:38 AM by imstac. 21 replies.
Page 2 of 2 (22 items) < Previous 1 2
Sort Posts: Previous Next
  • 03-04-2010 09:13 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Code behind for button to update to a SQL table

    Jimmy,

    I have added the ProjectForm.xsn and mapped it to my project table as instructed.  I also added my other form (Job Setup Form) as a doctype and mapped its fields.  When I try to create a new document from the Job Setup Form doctype I get the following error:

    InfoPath cannot open the selected form because of an error in the form's code.
    One or more required components of InfoPath or the form template cannot run because of a security restriction.
    Contact your system administrator or run Setup again to confirm that .NET Programmability Support is installed on your computer.
    Request for the permission of type 'Microsoft.Office.InfoPath.InfoPathPermission, Microsoft.Office.InfoPath.Client.Internal.Host, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

       at Microsoft.Office.Interop.InfoPath.SemiTrust.XDocumentsCollectionWrapper.NewFromSolution(Object varURI)
       at AdminTool.Configuration.btnNewDocument_OnClick(DocActionEvent e)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

     Do you think this has something to do with the setup we did to create a new project?  This coding shouldn't be accessing my individual computer, correct?

    Stacie
  • 03-04-2010 09:40 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Code behind for button to update to a SQL table

    Hey Jimmy,

    I figured it out.  I did a search on the InfoPath Dev site and found a post that said the error happens when there is C# code specified even if there is no code within the form.  I went to Form Options | Programming and clicked the Remove Code form, saved and reposted to doctype in DBXL and it worked.

     Yippeee!

     Thanks so much for all your help...you're a lifesaver!

    Stacie
  • 03-04-2010 04:38 PM In reply to

    Re: Code behind for button to update to a SQL table

     Hey Stacie,

    I'm glad you got it straightened out.  Happy DBXL'ing! :-)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-18-2010 09:34 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Code behind for button to update to a SQL table

    Hey Jimmy,

    Sorry to bother you again but I am trying to add some additional fields to be populated in my Projects table and I can't get the data to populate in the additional fields.  Here's what I have done so far:

    1. Opened the ProjectsForm in design mode and added two new fields to my main data source; Market and Location
    2. Saved the form.
    3. Went to the DBXL Admin Tool and deleted the ProjectsForm form and then readded it.
    4. Went to the database tab and mapped my Location and Market fields in my database to the form fields. Saved my configuration
    5. Opened my Job Survey Infopath form and updated my data connection to the updated template.xml file.
    6. Right-clicked on the Create Project button and updated the my Set XML to Submit rule as follows:

    concat('<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:ProjectsForm:-myXSD-2010-02-27T08-03-19" href="manifest.xsf" solutionVersion="1.0.0.3" productVersion="12.0.0" PIVersion="1.0.0.0" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-02-27T08:03:19" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"><my:name><![CDATA[', tbox_jobnamepost, "]]></my:name><my:status>3</my:status><my:branch_office>", ddl_branchoffice, "</my:branch_office><my:owner>", ddl_ownername, "</my:owner><my:location>", tbox_location, "</my:location><my:market>", ddl_Market, "</my:market></my:myFields>")

    I tested createing a new project in my Job Survey form and it updates the record but it doesn't update the additional fields I added; only the ones that you originally coded for me.I checked the messages in my eventviewer and did not see any errors.

    Am I missing a step?

    Stacie
  • 03-18-2010 09:36 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Code behind for button to update to a SQL table

    Attached is my Job Survey form.

     

    Stacie
  • 03-18-2010 05:34 PM In reply to

    Re: Code behind for button to update to a SQL table

    Hello again Stacie,

     Could you try going to the Documents tab for the ProjectForm in DAT and opening up one of the newly submitted forms to see if the new field values are present in them?  Here I'm supposing you added controls to the view to show their value.  That's one way of trying to find out where the disconnect is happening.

    Just one note - you can update a doctype's XSN - even if you've added new fields - without deleting and recreating the doctype.  You can just attach the new XSN in the General tab and click Save.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-19-2010 08:38 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Code behind for button to update to a SQL table

    Thanks Jimmy.  So I took your advice and added the controls to my ProjectForm form and then tried submitting in my other form.  When I tried to open the ProjectForm that was submitted I got a helpful error.  The problem was that the new fields in which I added in the ProjectForm had the first letter capitalized.  When I updated the xml in the rules in my other form I used all lowercase letters.

    Thanks for your help again!

    Stacie
Page 2 of 2 (22 items) < Previous 1 2
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.