InfoPath Programming Tutorial(s) - InfoPath Dev
in

InfoPath Dev

InfoPath Programming Tutorial(s)

Last post 04-25-2013 11:57 AM by RobSil1976. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-25-2013 09:56 AM

    InfoPath Programming Tutorial(s)

    Is there anyone that can point me to some basic/beginner level videos so I can get the gist of programming in Visual Basic in InfoPath?

     Honestly, some sample code of pushing/pulling values from a single textbox would probably suffice. I can figure the rest out. I'm just looking how to get started...

    Thank you in advance for any helpful input. 

  • 04-25-2013 10:55 AM In reply to

    Re: InfoPath Programming Tutorial(s)

    Does it have to be Visual Basic?  I can share some code I wrote in C# if that helps.

    R.

  • 04-25-2013 11:06 AM In reply to

    Re: InfoPath Programming Tutorial(s)

     Yes, I will take C#. I would still like to hunt down some VB code though.

  • 04-25-2013 11:57 AM In reply to

    Re: InfoPath Programming Tutorial(s)

    Ok here is one to get you started, bear in mind I use Infopath Filler 2007 so can't guarantee what doesn't work with web version... I've paraphrased my variable names a bit but should be fairly compilable :).

    //To take value from dropdown list then query DB by it as a parameter...
      public void SomeButton_Clicked(object sender, ClickedEventArgs e)
            {
                XPathNavigator xpn = (XPathNavigator)e.Source;
    
                xpn.MoveToChild("MyDropDownListElement", xpn.NamespaceURI);
                
                string param = xpn.Value;
                if (string.IsNullOrEmpty(param)) {
                    MessageBox.Show("Please select a valid entry from the dropdown and try again.", "Error");
                    return;
                }
    
                if (!IsFormEmpty) {
                    if (MessageBox.Show("You are about to load load data " + param+ ".  Any unsaved changes to the current data are about to be lost.  Do you wish to proceed?",
                                "Confirm Load", MessageBoxButtons.YesNo) == DialogResult.No)
                        return;
    
                    
                    LoadSomeTestData(param);
            
                    IsFormEmpty = false;
                    return;
                }            
            }
    
          private void LoadSomeTestData(string param)
            {
    
                string query = "SELECT [ColName1],[ColName2] FROM [DB_NAME].[dbo].[TableName] WHERE ColName1 = '" + param + "'"; ;
    
                AdoQueryConnection myAdoQueryConnection =
                       (AdoQueryConnection)(this.DataConnections["MY_DB_CONNECTION"]);
                string oldCmd = myAdoQueryConnection.Command;
                myAdoQueryConnection.Command = query;
                myAdoQueryConnection.Execute();
                myAdoQueryConnection.Command = oldCmd;
    
                XPathNavigator queryNav = this.DataSources["MY_DB_CONNECTION"].CreateNavigator();
                queryNav =  queryNav.SelectSingleNode("//dfs:myFields/dfs:dataFields/d:TableName", this.NamespaceManager);
    
       //And so on, now iterate the main fields and the data fields and swap out the data using XPath cmds.
            }
    
    
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.