From Sharepoint List to Access DB - InfoPath Dev
in

InfoPath Dev

From Sharepoint List to Access DB

Last post 04-23-2013 05:48 PM by Hilary Stoupa. 35 replies.
Page 3 of 3 (36 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 02-28-2013 07:26 AM In reply to

    Re: From Sharepoint List to Access DB

    Hilary,

    How do you read the results of the query and use it in your InfoPath Form?  After the .Execute() how would you see what came back from the DB?

    Thx,

    Rob

  • 02-28-2013 12:06 PM In reply to

    Re: From Sharepoint List to Access DB

    Hilary Stoupa

  • 04-23-2013 07:49 AM In reply to

    • ndisa
    • Not Ranked
    • Joined on 04-23-2013
    • Posts 2

    Re: From Sharepoint List to Access DB

    Hi Hilary,

     I successfully built a form that utilizes your code to do wildcard searches. In that form the data connection is the "Main" Data connection.  However when I decided to create a new form wherein the data I want to wildcard query is not the "main" but rather the "Secondary" data connection I get the following errors:

    System.NullReferenceException
    Object reference not set to an instance of an object.
       at DataMining_v2.FormCode.BtnQuery_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Below is my code but is really yours with a little change:

    XPathNavigator queryField = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:Provider_Info/@Provider_Name", NamespaceManager);

    string querySeed = queryField.Value;

    queryField.SetValue("");

    string customQuery = " where ([Provider Name] like '%" + querySeed + "%')";

     

    AdoQueryConnection newQuery = (AdoQueryConnection)MainDataSource.QueryConnection;

    string origCommand = newQuery.Command.ToString();

    newQuery.Command = origCommand + customQuery;

    newQuery.Execute();

    newQuery.Command = origCommand;

    queryField.SetValue(querySeed);

     

    Any suggestions or direction pointing would be greatly appreciated.

     ndisa

  • 04-23-2013 08:15 AM In reply to

    Re: From Sharepoint List to Access DB

     So, your issue is here:

     XPathNavigator queryField = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:Provider_Info/@Provider_Name", NamespaceManager);

    This is because your XPath is not a field in the main data source, so queryField is null. You need something like the below example, replacing NAME OF YOUR DATA SOURCE GOES HERE with your data source name.

    XPathNavigator queryField = this.DataSources["NAME OF YOUR DATA SOURCE GOES HERE"].CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:Provider_Info/@Provider_Name", NamespaceManager);

    Hilary Stoupa

  • 04-23-2013 10:58 AM In reply to

    • ndisa
    • Not Ranked
    • Joined on 04-23-2013
    • Posts 2

    Re: From Sharepoint List to Access DB

    Thanks Ill let you know if I get it worked out. One other question is there a way to query with multiple words? I am getting no returns if I use two words.  Exp: "Lansing" I get multi returns (Lansing & East Lansing" If I search on "East Lansing" I get 0 returns.

    Nick

  • 04-23-2013 05:48 PM In reply to

    Re: From Sharepoint List to Access DB

     Can you test your intended query in SQL Manager? That is to say - a like clause should work w/ 2 or more words - like '%East Lansing%'

    Hilary Stoupa

Page 3 of 3 (36 items) < Previous 1 2 3
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.