locked
Cannot get Contains or Like Clause to work RRS feed

  • Question

  • Thanks for the help diagnosing the issue with the Master Page breaking my query. Using the rendered form name solved that problem.  Now I have an issue wuth setting up the search to use a CONTAINS or LIKE clause rather than a EQUAL.

    If I try to define a CONTAIN clause Web Expression generates an error: There was an error executing the query. Please check the syntax of the command and if present, the types and values of the parameters and ensure they are correct.

    Syntax error (missing operator) in query expression ‘(CONTAINS([ACCTNAME]),?))’.

    I am using  FORM and the rendered form field name when buinding the where clause. Here are the three SQL statements that are generated

    EQUALS (This One Works)

    SELECT [ACCT], [DATE_SP], [DATE_RET], [ACCTNAME] FROM [Table1] WHERE ([ACCTNAME] = ?)

    CONTAINS (This one creates the error above & retuns no rows)

    SELECT [ACCT], [DATE_SP], [DATE_RET], [ACCTNAME] FROM [Table1] WHERE (CONTAINS([ACCTNAME], ?))


    LIKE (This one retuns no rows)

    SELECT [ACCT], [DATE_SP], [DATE_RET], [ACCTNAME] FROM [Table1] WHERE ([ACCTNAME] LIKE '%' + ? + '%')

    Monday, January 24, 2011 2:08 PM

Answers


  • There are definite issues working with controls within content placeholders of Master pages especially if you are trying to pass data from one page to another.

    You invariably get involved with using FindControl to dig the control values out of the Master Page, which can get messy and sometimes does not work as you expect it to. And as previously mentioned, the asp.net forum has more people working with that kind of issue.



    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with FP, Access, Bots and Wizards
    LawOfAllTheLand.org -- Created with Expression, VWDExress, SQL Express, and ASP.NET.
    Arvixe -- My favored web host
    • Marked as answer by cduchon Wednesday, January 26, 2011 12:31 AM
    Monday, January 24, 2011 3:33 PM

All replies

  • Just wanted to clarify... The LIKE clause DOES work if I dont have a MAster Page attached to the postback screen... the CONTAINS clause doesnt work at all.
    Monday, January 24, 2011 2:18 PM
  • forums.asp.net
    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.
    Monday, January 24, 2011 3:06 PM

  • There are definite issues working with controls within content placeholders of Master pages especially if you are trying to pass data from one page to another.

    You invariably get involved with using FindControl to dig the control values out of the Master Page, which can get messy and sometimes does not work as you expect it to. And as previously mentioned, the asp.net forum has more people working with that kind of issue.



    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with FP, Access, Bots and Wizards
    LawOfAllTheLand.org -- Created with Expression, VWDExress, SQL Express, and ASP.NET.
    Arvixe -- My favored web host
    • Marked as answer by cduchon Wednesday, January 26, 2011 12:31 AM
    Monday, January 24, 2011 3:33 PM
  • I marked the previous post as answered. Thanks for the reminder

    Monday, January 24, 2011 6:40 PM