SQL-lite select using AND operator

Discussion in 'Questions (Windows Mobile)' started by mozaharul, Jun 2, 2008.

  1. mozaharul

    mozaharul Active Member Licensed User

    I am trying to select rows from a database depending on 2 conditions. Tried to use AND but this did not work (see code below). Any suggestions?

    cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = "&txthhidm.Text&" & AND & motherno = "&(txthhidm.Text&*100)+&txtmemno.Text&""

    Regards
     
  2. giannimaione

    giannimaione Well-Known Member Licensed User

    Hi Mozaharul,

    try it:

    cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = " & txthhidm.Text & " AND motherno = " & ((txthhidm.Text*100) + txtmemno.Text)

    or
    YourQuery="select name,perm_id,permid_moth from motherno where hpid = " & txthhidm.Text & " AND motherno = " & ((txthhidm.Text*100) + txtmemno.Text)
    msgbox(YourQuery):' only for testing :)
    cmd.CommandText=YourQuery

    are you sure that txthhidm and txtmemno are ONLY numeric value??? :confused:
     
  3. mozaharul

    mozaharul Active Member Licensed User

    Hi giannimaione,

    Thanks for the help.

    txthhidm and txtmemno are both numeric value.

    I'm not clear about the last two quotes have been dropped from my code. Off course, the syntax generated error. Could you please explain ?


    Best regards,

    Mozaharul
     
  4. giannimaione

    giannimaione Well-Known Member Licensed User

    Hi mozaharul

    in your code there are two errors syntax
    1) & AND &
    2) &txtmemno.Text&""

    Sorry, but i am not more explain , and i am sorry for my bad english :sign0013:
     
  5. mozaharul

    mozaharul Active Member Licensed User

    Hi giannimaione,

    Its OK, thanks for the explanation.


    regards,
     
  6. giannimaione

    giannimaione Well-Known Member Licensed User

    missing quotes

    Hi mozaharul
    :sign0013: i have missing quotes

    here i have correct code:
    cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = '" & txthhidm.Text & "' AND motherno = " & ((txthhidm.Text*100) + txtmemno.Text)
    :sign0188:
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice