Dynamically changing DBEnum parameters - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Dynamically changing DBEnum parameters

Last post 11-28-2007 11:39 AM by ErnestoM. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 11-20-2007 02:28 PM

    Dynamically changing DBEnum parameters

    I have succesfully created a form based on a Web Service that allows the user to dynamically change the parameters used to query the Database Enumeration Service. The user enters a database and a table and clicks a button to launch the query.

    However, now I'd like to allow the user to create the filtering query on the fly. I can use concat to "gather" and arrange various input fields into the filtering query, but I don't know how to insert the contents of this fields into the .

    I notice that when I save the source files I do not get a GetColumnsForRows2.xml that I can edit (as indicated in the help documents). I notice that the filter queryXML is created as a section, but I'm unable to edit it (see Data Source attached).

    So, to summarize my goal: query using DBEnum, by allowing the user to feed each piece of information (database, table, column, queryxml filter) into a form and click a button, instead of "hard-coding" all that information using the Data Connection Wizard.

    Thanks!


    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 11-20-2007 06:16 PM In reply to

    Re: Dynamically changing DBEnum parameters

    Hi Ernesto,

     This scenario is why there are two versions of this method: 2 and 2b.  If you use the 2b method, the queryXml node will show up as a regular textbox node in the schema, just like database and table.  With this node you can fill it with the result of a concat() operation that takes values from other nodes and generates an XML fragment from them.

    So, you would create another secondary data connection, called QueryBuilder, and it will have the schema of the actual queryXml node.  After that is filled out, you can use a concat() (probably combined with some complicated eval() operations) to generate the XML fragment.  Then assign this fragment to the queryXml node, and you should be set!

    Hope this helps!

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 11-21-2007 01:10 PM In reply to

    Re: Dynamically changing DBEnum parameters

    Great! Thanks.

    Now I'm looking at a separate problem. Basically, after receiving the user input and using concat this is the query I have (user input in bold):

    <query><filter><like><column name=Name /><value>%1</value></like></filter></query>

    And this is the query I need:

    <query><filter><like><column name="Name" /><value>%1</value></like></filter></query>

    I'm using concat and it won't allow me to use a double quote (") around the column name. I've posted that question here: http://www.infopathdev.com/forums/p/5083/19570.aspx

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 11-26-2007 03:10 PM In reply to

    Re: Dynamically changing DBEnum parameters

    I've been able to create my query and include the double quotes, thanks to a reply in the topic linked in my previous response. I'm currently using a rule that concatenates the values provided by the user to create the following query:

    <query><filter><like><column name="Name" /><value>%1</value></like></filter></query>

    It looks ok and it has been tested: I created a simple Infopath form that calls DBEnum using this filtering query and it works perfectly.

    However, in the solution where I allow the user to dynamically change the values, the query fails, with the following error:

    The SOAP response indicates that an error occurred on the server:

    System.Web.Services.Protocols.SoapException: El servidor no puede procesar la solicitud. ---> System.ArgumentException: Invalid parameter
    Nombre del parámetro: queryXml ---> System.Xml.XmlException: Los datos del nivel de raíz no son válidos. Línea 1, posición 1.
       en System.Xml.XmlTextReaderImpl.Throw(Exception e)
       en System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
       en System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res)
       en System.Xml.XmlTextReaderImpl.ParseDocumentContent()
       en System.Xml.XmlTextReaderImpl.Read()
       en System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
       en System.Xml.XmlDocument.Load(XmlReader reader)
       en System.Xml.XmlDocument.LoadXml(String xml)
       en Qdabra.DataBaseService.DatabaseEnumerationService.GetColumnsForRows2b(String database, String table, String queryXml)
       --- Fin del seguimiento de la pila de la excepción interna ---
       en Qdabra.DataBaseService.DatabaseEnumerationService.GetColumnsForRows2b(String database, String table, String queryXml)
       --- Fin del seguimiento de la pila de la excepción interna ---

    If the queryxml works when I insert it manually, why would it fail when the form injects it automatically?

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 11-26-2007 08:20 PM In reply to

    Re: Dynamically changing DBEnum parameters

    Hi Ernesto,

    I'm wondering if it has something to do with the double quotes getting escaped. Can you try changing the double quotes to single quotes and see if that makes a difference? 

    Patrick Halstead
    Project Manager at Qdabra
  • 11-27-2007 04:10 PM In reply to

    Re: Dynamically changing DBEnum parameters

    Hi Patrick, single quotes return the same error.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 11-27-2007 07:45 PM In reply to

    Re: Dynamically changing DBEnum parameters

    In one that I have working, I have to concat the single quotes seperately. Not sure if this helps or not but thought that I would add this.

    so concat(....<eq><column name=", "'", "Name", "'", "/><value...)

  • 11-27-2007 11:13 PM In reply to

    Re: Dynamically changing DBEnum parameters

    Also, be sure that you are not URL encoding in your concat()... Let InfoPath do that itself.

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 11-28-2007 11:39 AM In reply to

    Re: Dynamically changing DBEnum parameters

    Oh, that was simple! Thanks Matt.

    Because the problem was elsewhere, it turns out that it doesn't matter which quotes (single or double) are used. I was succesful using Clay's reccommendation for inserting single quotes, as well as a reccommendation from this topic (http://www.infopathdev.com/forums/p/5083/24578.aspx#24578), where the double quotes are stored in a separate xml node and inserted in the concat statement. Note, however, that double quotes cannot be inserted within double quotes (i.e. """).

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


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