M mozaharul Active Member Licensed User Jun 2, 2008 #1 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
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
Gianni M Well-Known Member Licensed User Longtime User Jun 2, 2008 #2 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???
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???
M mozaharul Active Member Licensed User Jun 3, 2008 #3 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
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
Gianni M Well-Known Member Licensed User Longtime User Jun 3, 2008 #4 Hi mozaharul mozaharul said: cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = "&txthhidm.Text&" & AND & motherno = "&(txthhidm.Text&*100)+&txtmemno.Text&"" Click to expand... 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:
Hi mozaharul mozaharul said: cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = "&txthhidm.Text&" & AND & motherno = "&(txthhidm.Text&*100)+&txtmemno.Text&"" Click to expand... 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:
M mozaharul Active Member Licensed User Jun 4, 2008 #5 Hi giannimaione, Its OK, thanks for the explanation. regards,
Gianni M Well-Known Member Licensed User Longtime User Jun 4, 2008 #6 missing quotes Hi mozaharul :sign0013: i have missing quotes cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = " & txthhidm.Text & " AND motherno = " & ((txthhidm.Text*100) + txtmemno.Text) Click to expand... 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:
missing quotes Hi mozaharul :sign0013: i have missing quotes cmd.CommandText="select name,perm_id,permid_moth from motherno where hpid = " & txthhidm.Text & " AND motherno = " & ((txthhidm.Text*100) + txtmemno.Text) Click to expand... 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: