locked
Problem with TableAdapter Query. Please help... RRS feed

  • Question

  • Hi,

    I am using MS Access and VB.Net 2005. I need to perform 'search' in my application.

    I add query1 in table adapter, which will SELECT rows,(SELECT name, age FROM human WHERE gender LIKE ?).

    I add query2 in the same table adapter, (SELECT name, age FROM human WHERE age LIKE ?)

    My question is, if I want to perform two level search, means after the first 'query', I want to execute the second query on the "result" of first 'query'.

    For example, I search all "Male" in first query, after that, I want to filter all "Male" that their 'age' is 20.

    I tried the following code,
    Me.HumanTableAdapter.SearchGender(Me.DataSet.human, "Male")

    Me.HumanTableAdapter.SearchAge(Me.DataSet.human, "20")

    the result is all the human age 20, no matter it is male or female.

    I have no idea what's going wrong. Can somebody please advise?
    Thank you very much!


    Best Regards,
    Boon

    p/s: Due to some function requirement of my application, I cannot combine the two queries into one. Sometime may only need to execute query2.

    Sunday, April 1, 2007 7:07 AM

Answers

  • Hi,

     

    May I ask why you use LIKE ?

     

    Try your queries with = instead to see if it changes the behavior. It's not like there are that many genders to distinguish from . If you think there might be a problem in the way people enter the gender in the table, then you should validate the data before writing it to the table (this should always be done anyway).

     

    Also, using LIKE on numbers sounds a bit scary to me.

     

    Hope this helps.

     

    Luc.

    Tuesday, April 3, 2007 12:54 PM