Refresh Secondary Data Source Connection via code... - InfoPath Dev
in

InfoPath Dev

Refresh Secondary Data Source Connection via code...

Last post 10-11-2010 12:08 AM by colecg. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 03-11-2008 04:08 PM

    Refresh Secondary Data Source Connection via code...

    Hello,

        I have a data connection that recieves data from a sharepoint list.  I would like to refresh this secondary data source using custom code :S. I know that I can achieve this by using a refresh button or a query action, but that wont help to what I am trying to do... so, Is there any way to refresh a data connection via code?.


    Thanks in advance,

     
    Omar
     

  • 03-11-2008 05:11 PM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    Hello Omar and welcome to the forums!

    It's pretty easy to achieve what you to do, all you need is to get the data connection object in code and call a query method on it. However this will differ between versions of InfoPath.

    What version of InfoPath are you using? What language are you writing your custom code in?

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-11-2008 05:16 PM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    Thank you for answering so quickly...

     I am using InfoPath 2007 and C#.

     

    Omar
     

  • 03-11-2008 05:37 PM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    Assuming you are using InfoPath 2007-style OM (InfoPath 2007 allows you to use both 2003 and 2007 object models, 2007 is preferred) you can (re)query the dataconnection by calling the Execute() method on it. For example, if your connection is called MySharePointListConnection, you can refresh it by calling the following line from your code:

    this.DataConnections["MySharePointListConnection"].Execute();

    I hope this answers your question.

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-13-2008 11:12 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    Thanks a lot, this was exactly what I was looking for, although I was trying to do this as a possible workaround to a weird error problem I had with InfoPath Forms Services.  I had a custom list in SharePoint which name was "Acción"... aparently you can't use a Data Connection to get this list because of the "ó" character :S. I heard there is a hotfix for this, but what I did was to recreate the list without any weird character on its name, and all worked fine..  thanks again for your help.

    Omar
     

  • 10-04-2010 11:48 PM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    Hi.

    I am also using InfoPath 2007 and SharePoint 2007 and C# for code behind of InfoPath.

    I have tried this but it still does not collect new rows from repeating tables from secodnary sources.

    Any help?

  • 10-05-2010 08:34 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    You'll need to post your code for people to be able to help you -- what are you currently doing? What is going wrong?
    Hilary Stoupa

  • 10-05-2010 10:31 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

     

    Hi, can you check if the items limits in your sharepoint default view is reach ? if yes increase it.
  • 10-07-2010 12:22 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    I have tried referencing this method from

    FormEvents_Loading and from  InternalStartup

    because I need it to check for new rows on next opening of the form

    public void refreshDataSources()

    {

    for (int i = 0; i < this.DataConnections.Count; ++i)

    {

    this.DataConnections[i].Execute();

    }

    }

    Use of button is not an option because I need to bring rows prior to displaying the form to user.

    For my own testing purpose I have tried using the button but no luck.

    Thank you for your time

    Regards

    Amira

  • 10-10-2010 07:32 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

     Hi, for the load event, you can just check "automatically retrieve information".

  • 10-11-2010 12:08 AM In reply to

    Re: Refresh Secondary Data Source Connection via code...

    If you are talking about checking the box "Automatically retrieve data when form is opened" while creating data connection, I have that checked from the begining.

    Thank you for your help

    Regards,

    Amira

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