Custom Queries for data connections - InfoPath Dev
in

InfoPath Dev

Custom Queries for data connections

Last post 02-21-2006 06:07 PM by delu. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-20-2006 11:10 PM

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Custom Queries for data connections

    I made a data connection with a custom query, that looks like this:

    SELECT DISTINCT
    CASE isActive
    when 1 then 'yes'
    when 0 then 'no'
    else 'unknown'
    end AS isActive
    FROM [dbo].[Members]


    I bound this data connection to a list box and it works fine.
    I call this data connection from manage code:

    thisXDocument.DataObjects[secondary].Query();

    and it still works fine.

    But when I change the query with manged code, I get no
    return set:


    ADOAdapter oSecondary;
    oSecondary = ADOAdapter)thisXDocument.DataObjects[secondary].QueryAdapter;
    oSecondary.Command = "SELECT DISTINCT " +
    " CASE " + column +
    " WHEN 0 THEN '" + c0 + "'" +
    " WHEN 1 THEN '" + c1 + "'" +
    " ELSE 'unknown'" +
    " END AS " + column +
    " FROM " + table + " ORDER BY " + column;
    thisXDocument.DataObjects[secondary].Query();


    Can anybody help me?

    Thanks in advance!

  • 02-21-2006 12:01 PM In reply to

    Re: Custom Queries for data connections

    Hi,
    Try the following queries they might help you out

    Dataconnection query
    SELECT DISTINCT
    CASE isActive
    when 1 then 'yes'
    when 0 then 'no'
    else 'unknown'
    end AS isActive
    FROM [dbo].[Members] as Members

    and your code query should look like
    "SELECT DISTINCT " +
    " CASE " + column +
    " WHEN 0 THEN '" + c0 + "'" +
    " WHEN 1 THEN '" + c1 + "'" +
    " ELSE 'unknown'" +
    " END AS isActive" +
    " FROM " + table + "as Members ORDER BY " + column;


    Agni
    INFOPATHdev India
  • 02-21-2006 06:07 PM In reply to

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Re: Custom Queries for data connections

    It works fine :)
    Thanks a lot!!
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.