Filling drop down via XML service - InfoPath Dev
in

InfoPath Dev

Filling drop down via XML service

Last post 05-18-2009 05:51 AM by cgiguere. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-17-2009 04:51 AM

    Filling drop down via XML service

     Hello,

    I want the user to be able to select a Client from a drop down. I created a webservice that queries my database and retrieves the ClientID en ClientName. I want to show the ClientName in my dropdown.  How do I do that? In VB projects, I can simply assign the values to Control.text but I cannot do this in my webservice.

    When I try to bind my control to my secondary webservice data source, I get the Infopath message that I have to use a "repeating field". I am all confused. I do not want the user to add many clients on their form, but rather to be able to select from a drop down the desired client.

    Very basic question, I know, but I am trying alone for more than 3 days and I am getting no where. I get examples of very complex codes on the internet but I really want to keep it as simple as possible.

    Your help will be greatly appreciated.

    cg

    Filed under:
  • 05-17-2009 10:48 PM In reply to

    Re: Filling drop down via XML service

    Hi

    The field or group that needs to bind from the secondary dom to dropdown should be repeating.By binding the dropdown to repeating field or group does not make the field repeating in UI.User can fill the drop down only once.

    Madhuri
    http://www.ggktech.com
  • 05-17-2009 11:06 PM In reply to

    Re: Filling drop down via XML service

    Hi CG,

    Your web service probably isn't returning multiple rows when you query it with nothing. When InfoPath connects to the Web Service, it tries to infer the schema based on what the WSDL returns. If you change that, it will identify it as repeating. Hope this helps.

     

    Patrick Halstead
    Project Manager at Qdabra
  • 05-18-2009 12:51 AM In reply to

    Re: Filling drop down via XML service

    Hi Patrick,

    Thank you for your prompt reaction. My webservice is quering a table (Select ClientName from Client). Below is my webservice. When I run the code in

     Public Function GetKlantenLijst() As Klanten

            'Declarations...
            Dim myConnection As New SqlConnection _
                (System.Configuration.ConfigurationManager.ConnectionStrings("Jobtraining_testConnectionString").ConnectionString)

            Dim myDataAdapter As New SqlDataAdapter()  'da properties at Fomr1_Load event
            Dim myDataSet As DataSet = New DataSet()
            Dim dr As SqlDataReader

            'set the select command properties...
            myDataAdapter.SelectCommand = New SqlCommand

            myDataAdapter.SelectCommand.Connection = myConnection
            myDataAdapter.SelectCommand.CommandText = _
                "Select Bedrijf FROM Klanten
            myDataAdapter.SelectCommand.CommandType = CommandType.Text

            'Open db connection...
            myConnection.Open()

            'Execute command...
            dr = myDataAdapter.SelectCommand.ExecuteReader()
            dr.Read()

            Dim Klanten As New Klanten()
            Klanten.Bedrijf = dr("Bedrijf")

            'Close db connection...
            myConnection.Close()

            Return Klanten

        End Function

     

    When I run the webservice I get this 

    De volgende bewerkingen worden ondersteund. Zie voor een formele definitie de servicebeschrijving.

    • GetContactInfo
    • GetKlantNaam
    • GetKlantenLijst
    • GetUitvoeringslocatieInfo
    • HelloWorld

     I see my function "GetklantenLijst" but when I test what it returns, I get this:

    BODY{font:x-small 'Verdana';margin-right:1.5em} .c{cursor:hand} .b{color:red;font-family:'Courier New';font-weight:bold;text-decoration:none} .e{margin-left:1em;text-indent:-1em;margin-right:1em} .k{margin-left:1em;text-indent:-1em;margin-right:1em} .t{color:#990000} .xt{color:#990099} .ns{color:red} .dt{color:green} .m{color:blue} .tx{font-weight:bold} .db{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;border-left:1px solid #CCCCCC;font:small Courier} .di{font:small Courier} .d{color:blue} .pi{color:blue} .cb{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;font:small Courier;color:#888888} .ci{font:small Courier;color:#888888} PRE{margin:0px;display:inline}0) fix(e,"cb");} if (e.className=="di"){if (e.children(0).innerText.indexOf("\n")>0) fix(e,"db");} e.id=""; } function fix(e,cl){ e.className=cl; e.style.display="block"; j=e.parentElement.children(0); j.className="c"; k=j.children(0); k.style.visibility="visible"; k.href="http://www.infopathdev.com/forums/AddPost.aspx?ReplyToPostID=41811&Quote=False#"; } function ch(e){ mark=e.children(0).children(0); if (mark.innerText=="+"){ mark.innerText="-"; for (var i=1;i

      <?xml version="1.0" encoding="utf-8" ?>
    - <Klanten xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
      <Bedrijf>CGSoft</Bedrijf>
      <KlantID>0</KlantID>
      </Klanten>
     
    However this test table has 3 entries. Further, I cannot bind my drop down to this data source because I receive the message that it need a repeating field! What is a repeating field? and why does my service only returns one row of the 3?
     
    If you can help me Patrick, I would really appreciate!
    Regards,
    Christiane
     

     

    Filed under: ,
  • 05-18-2009 01:25 AM In reply to

    Re: Filling drop down via XML service

     Thank you Maduri,

     Maybe this is a very stupid question but how do you bound a drop down to a repeating "field"? What is a repeating field? I only use the controls and bind the controls directly to the secondary data source. As controls, I have the choice between drop down and repeating table or repeating section, amongst others. What do you mean by "the field that needs to be bind from the data source"? If I understand you right, this "field" is my drop down, right?

    THnaks in advance

  • 05-18-2009 04:33 AM In reply to

    Re: Filling drop down via XML service

    A dropdown list is bound to a single node, and the selected value on the dropdown box is stored in that node.  The values, however, must originate from a repeating node somewhere in the form.  This is necessary in order to have more than just one option.

    When you expand the nodes in the secondary data connection that's connected to that web service, does any node have a small blue rectangle with a white arrow pointing down?  That would be the repeating node.  I'm not really sure what a "Klanten" is so I don't know if it would typically have a repeating aspect to it, but from your code it looks like you're only storing a single value in it.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-18-2009 05:51 AM In reply to

    Re: Filling drop down via XML service

     Hello Jimmy,

    No, I do not have a small blue rectangele with a white arrow. It appears than, that my secondary data source had no repeating node. How do we make it repeating?

    Thanks in advance,

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