delphi dynamic sql in delphi 7 -
hello how can prepare dynamic in sql form elemants edit1,edit2,edit3 , datetimepicker1,2
if user cannot select datetimepicker query must select * table if user select datetimepicker buttom question ok user not select edit1 null , edit2 null
select edit3 selected how create query
adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('where siptar>='); adoquery1.sql.add(quotedstr(datetostr(datetimepicker1.datetime)+' 00:00:00.000')+' , siptar <='); adoquery1.sql.add(quotedstr(datetostr(datetimepicker2.datetime)+' 23:59:59.000') );
adoquery1.open;
i found neccesary code..
adoquery1.sql.clear; adoquery1.sql.add(' select ck.cname,si.rkod,sk.location,sk.sipno,sh.skod,convert(varchar(50),sk.siptar,105)as siptar siparis_kay sk'); adoquery1.sql.add(' left join siparis_har sh on sh.sipno=sk.sipno'); adoquery1.sql.add(' left join cari_kart ck on ck.ckod=sk.carikod'); adoquery1.sql.add(' left join si_gchar si on si.fisno=sh.sipno , si.fisharinx=sh.sipharinx , si.skod=sh.skod'); adoquery1.sql.add( 'where 1=1' ); if edtstok.text <> '' adoquery1.sql.add('and sh.skod >= '+ quotedstr(edtstok.text) ); if edtstok1.text <> '' adoquery1.sql.add('and sh.skod <= '+ quotedstr(edtstok1.text) ); if edtcari.text <> '' adoquery1.sql.add('and ck.ckod >= '+ quotedstr(edtcari.text) ); if edtcari1.text <> '' adoquery1.sql.add('and ck.ckod <= '+ quotedstr(edtcari1.text) ); if edtlocation.text <> '' adoquery1.sql.add('and sk.location = '+ quotedstr (edtlocation.text) ); adoquery1.sql.add('and siptar >= '+ quotedstr(datetostr(dtpbas.datetime)+' 00:00:00.000')); adoquery1.sql.add('and siptar <= '+quotedstr(datetostr(dtpbit.datetime)+' 23:59:59.997'));
Comments
Post a Comment