Ok i am very new to Programming..can someone pls tell me what I am doing wrong? - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Ok i am very new to Programming..can someone pls tell me what I am doing wrong? 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: Oldest to newest Newest to oldest Previous Next 07-30-2009 10:04 AM Rachel20J Joined on 12-13-2007 Houston Posts 21 Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Reply Contact 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) NextSubmitSubName.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 SubEnd Class End Namespace 07-30-2009 05:46 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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 Rachel20J Joined on 12-13-2007 Houston Posts 21 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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 Rachel20J Joined on 12-13-2007 Houston Posts 21 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact Could you paste in your code? Hilary Stoupa 08-12-2009 04:10 PM In reply to Rachel20J Joined on 12-13-2007 Houston Posts 21 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Ok i am very new to Programming..can someone pls tell me what I am doing wrong? Mark as Not AnswerMark as Answer... Reply Contact 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.
I am wanting to submit to webservice on click of button, i followed an example, using VS 2008, infopath 2007...
SubmitBCAmount.SetValue(values.SelectSingleNode(
SubmitChangeOrderNo.SetValue(values.SelectSingleNode(
submitCategory.SetValue(values.SelectSingleNode(
End
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...
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.
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()
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)
Could you paste in your code?
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)
Next End Sub
End Class
___________________________________________________________________________________________________________________________________________________________________
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText =
sqlCmd.Connection = sqlConn
sqlCmd.Parameters.Add(
sqlConn.Open()
sqlCmd.ExecuteNonQuery()
sqlConn.Close()
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?