Ok i am very new to Programming..can someone pls tell me what I am doing wrong? - InfoPath Dev
in

InfoPath Dev

Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

Last post 08-13-2009 11:34 AM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-30-2009 10:04 AM

    Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    I am wanting to submit to webservice on click of button, i followed an example, using VS 2008, infopath 2007...

     

    Public Sub CTRL370_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    Dim mainDataNavigator As XPathNavigator = MainDataSource.CreateNavigator()

    Dim SubmitSubName As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:SubName", NamespaceManager)

    Dim SubmitBCAmount As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:BCAmount", NamespaceManager)

    Dim SubmitContractNo As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:ContractNo", NamespaceManager)

    Dim SubmitChangeOrderNo As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:ChangeOrderNo", NamespaceManager)

    Dim submitJobnumID As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:JobNumID", NamespaceManager)Dim submitCategory As XPathNavigator = mainDataNavigator.SelectSingleNode("my:my:BackchargeGroup/my:BCList/my:Category", NamespaceManager)

     

    For Each values As XPathNavigator In mainDataNavigator.[Select]("my:my:BackchargeGroup/my:BCList", NamespaceManager)

    Next

    SubmitSubName.SetValue(values.SelectSingleNode("my:SubName", NamespaceManager).Value)

    SubmitBCAmount.SetValue(values.SelectSingleNode("my:BCAmount", NamespaceManager).Value)

    SubmitContractNo.SetValue(values.SelectSingleNode("my:ContractNo", NamespaceManager).Value)

    SubmitChangeOrderNo.SetValue(values.SelectSingleNode("my:ChangeOrderNo", NamespaceManager).Value)

    submitJobnumID.SetValue(values.SelectSingleNode("my:JobNumID", NamespaceManager).Value)

    submitCategory.SetValue(values.SelectSingleNode("my:Category", NamespaceManager).Value)

    DataConnections("BackChargeSubmit").Execute()

    End Sub

    End Class

    End Namespace

  • 07-30-2009 05:46 PM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    To start with, a bit more information would be helpful -- what are you trying to do? What example did you follow? Are you getting any errors?

    I can't help but notice you have a 'for each' loop with no action in between the for each and the next.... but then, there is a 'Select' inside square brackets that has me confused as well...

    Hilary Stoupa

  • 07-30-2009 07:02 PM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    Hello, I am trying to use button in infopath to submit values from repeating table into webservice to send to sql.  I've used this example...  http://www.infopathdev.com/forums/p/10879/38732.aspx  I am learning visual studio at the same time.  I am getting the underline in this example --> submitCategory.SetValue(values.SelectSingleNode("my:Category", NamespaceManager).Value).  I am not sure what I am doing.  Its not letting me complete my code to even see if it works.   I just have a simple repeating table that I would like to take those values and insert into the sql table.  Apologies as I was not complete with why I need help.  I've got a deadline coming up.

  • 07-31-2009 08:06 AM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    Hover your mouse over the word with the underline -- you should see a tip about why you have an error. You can also look in the error list window in Visual Studio.

    When I paste your code into a VB class, I get an error that values is not declared. That is because you declare the variable in this line:

    For Each values As XPathNavigator In mainDataNavigator.Select("my:my:BackchargeGroup/my:BCList", NamespaceManager)

    but you close your loop with 'Next' before you use it. Move 'Next' to below this line:

    DataConnections("BackChargeSubmit").Execute()

    Hilary Stoupa

  • 08-12-2009 11:49 AM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    thank you for your help so far Hilary!! I got those to work and now I am running into this...

    I have tried researching on this but its not clear to me..can someone hint at exactly what this means? I received this error in debugging..  Thank you.

    System.NullReferenceException occurred
      Message="Object reference not set to an instance of an object."
      Source="Acoustical Ceiling"
      StackTrace:
           at Acoustical_Ceiling.FormCode.CTRL370_5_Clicked(Object sender, ClickedEventArgs e)

  • 08-12-2009 02:38 PM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    Could you paste in your code?

    Hilary Stoupa

  • 08-12-2009 04:10 PM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    I have verified that my webservice works when adding dummy data and invoke, it writes everything in.  Here is form code:   Webservice code listed below the form code..

     Public Sub CTRL370_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                Dim mainDataNavigator As XPathNavigator = MainDataSource.CreateNavigator()
                Dim SubmitSubName As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:SubID", NamespaceManager)
                Dim SubmitJobNumID As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:JobNumID", NamespaceManager)
                Dim SubmitCategory As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:Category", NamespaceManager)
                Dim SubmitBCAmount As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:BCAmt", NamespaceManager)
                Dim submitContractNo As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:Contract", NamespaceManager)
                Dim submitChangeOrderNo As XPathNavigator = mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:CONumber", NamespaceManager)


                For Each values As XPathNavigator In mainDataNavigator.[Select]("my:myFields/my:BackchargeGroup/my:BCList", NamespaceManager)

                    SubmitSubName.SetValue(values.SelectSingleNode("my:SubName", NamespaceManager).Value)
                    SubmitBCAmount.SetValue(values.SelectSingleNode("my:BCAmount", NamespaceManager).Value)
                    SubmitContractNo.SetValue(values.SelectSingleNode("my:ContractNo", NamespaceManager).Value)
                    SubmitChangeOrderNo.SetValue(values.SelectSingleNode("my:ChangeOrderNo", NamespaceManager).Value)
                    SubmitJobNumID.SetValue(mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:JobNumID", NamespaceManager).Value)
                    SubmitCategory.SetValue(mainDataNavigator.SelectSingleNode("my:myFields/my:BackchargeGroup/my:Category", NamespaceManager).Value)

                    DataConnections("BackChargeSubmit").Execute()

              Next
         End Sub

        End Class

    ___________________________________________________________________________________________________________________________________________________________________ 

     <WebMethod()> _

    Public Sub AddBackCharge(ByVal SubcontractorID As String, ByVal JobNumberID As String, ByVal CSIID As String, ByVal BCAmount As String, ByVal ContractNumber As String, ByVal CONumber As String)

    Dim connString As String = ConfigurationManager.ConnectionStrings("USBIConnectionString").ToString

    Dim sqlConn As New SqlConnection(connString)

    Dim sqlCmd As New SqlCommand()

    Try

    sqlCmd.CommandType = CommandType.Text

    sqlCmd.CommandText = "INSERT INTO t_BackCharge (SubcontractorID, JobNumberID, CSIID, BCAmount, ContractNumber, CONumber) VALUES (@SubcontractorID, @JobNumberID, @CSIID, @BCAmount, @ContractNumber, @CONumber);"

    sqlCmd.Connection = sqlConn

    sqlCmd.Parameters.Add(New SqlParameter("@SubcontractorID", SubcontractorID))

    sqlCmd.Parameters.Add(New SqlParameter("@JobNumberID", JobNumberID))

    sqlCmd.Parameters.Add(New SqlParameter("@CSIID", CSIID))

    sqlCmd.Parameters.Add(New SqlParameter("@BCAmount", BCAmount))

    sqlCmd.Parameters.Add(New SqlParameter("@ContractNumber", ContractNumber))

    sqlCmd.Parameters.Add(New SqlParameter("@CONumber", CONumber))

    sqlConn.Open()

    sqlCmd.ExecuteNonQuery()

    Catch ex As Exception

    Throw New Exception("Error updating database", ex)

    Finally

    sqlConn.Close()

    End Try

    End Sub

  • 08-13-2009 11:34 AM In reply to

    Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong?

    Well, I'm not sure what line you are getting the error on -- you might want to set some break points in your code and debug to walk through it, or add some error handling.

    I am perplexed in general, though, by what you are doing. In the first section, you create some XPathNavigators from your main data source. Then, in your repeating section, you set those main data source fields to values from a repeating data source and execute a secondary data connection, which I assume is to your web service. When you set up the connection to your web service in InfoPath are you setting up a submit or receive connection? If submit, are you using those main data source nodes for your inputs?

    Hilary Stoupa

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