W
wanglong3
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了两种写法,为什么写法一不好使,而写法二好使呢??写法一procedure TForm1.Button2Click(Sender: TObject);vars1,s2:string;begin s1 := '2008-01-01 12:00:00'; s2 := '2009-01-01 12:00:00'; sql := 'select * from 日期表 where 日期2 between ' + s1 + ' and ' +s2; adoquery1.Close; adoquery1.sql.clear; adoquery1.sql.Add(sql); adoquery1.Open;end;写法二:procedure TForm1.Button2Click(Sender: TObject);vars1,s2:string;begin s1 := '2008-01-01 12:00:00'; s2 := '2009-01-01 12:00:00'; sql := 'select * from 日期表 where 日期2 between :sj1 and :sj2'; adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add(sql); adoquery1.Parameters.ParamValues['sj1'] := s1; adoquery1.Parameters.ParamValues['sj2'] := s2; adoquery1.Open;end;