Copy of data from DB - InfoPath Dev
in

InfoPath Dev

Copy of data from DB

Last post 08-31-2006 11:51 PM by tatopitta. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-29-2006 07:58 AM

    Copy of data from DB

    hi all,
    I have a secondary data connection with a SQL database to retrieve data to be displayed in a repeating table. I need to "copy" the values from the database in nodes of the XML document.Is it possible?

    Than you
  • 08-31-2006 12:13 AM In reply to

    Hi Tatopitta!
    Are you asking whether you can copy the values from your secondary data source to your main data source? If so, yes, but you'll either need a) rules for each field which could be a pain to manage, or b) write some code to do it. I hope this helps.
    Patrick Halstead
    Project Manager at Qdabra
  • 08-31-2006 12:22 AM In reply to

    Yeah Patrick,
    I'm trying to use JScript code but I have a problem:
    my SQL secondary datya source is named "ProjectManagers" but the following line

    var theDataObject = XDocument.DataObjects("ProjectManagers").DOM;

    gives me an error becouse the object is null...how can it be possible if the name ProjectManagers is correct?

    Can i set parameters for SQL statement in the datasource?

    Thank you very much!
  • 08-31-2006 12:43 AM In reply to

    Hi Patrick, forget the first question, please :)

    How can I use in my SQL statement a parameter which receives values from a XML field in the form?
  • 08-31-2006 12:49 PM In reply to

    You might take a look at this HowTo:http://www.infopathdev.com/howto/tutorials/default.aspx?i=0bb37b4de44348408680a53a449f2353 There is some code there that uses value typed into the XML to filter the results of the query.

    If you want to use code to create a custom SQL Query, take a look at this code (in C#, but you should be able to convert):


    // Get value from XML
    string name = thisXDocument.DOM.selectSingleNode( "//my:Name" ).text;

    // Set the query
    ADOAdapter dbConn = (ADOAdapter)thisXDocument.DataObjects["Project-WorkItems"].QueryAdapter;
    dbConn.Command = "SELECT col1, col2 FROM table WHERE Name = \"" + name + "\"";
    // Issue the query
    thisXDocument.DataObjects["Project-WorkItems"].Query();
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-31-2006 11:51 PM In reply to

    Thank you guys, you're great!
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.