不建议你这样做,你可以用一个datetimepicker取代combobox2,combobox3,如果需要这样做,可以用一下字符串拼凑:'select * from youtable where name='+#32+combobox1.tex+#32+' and youdate='+#32+yearof(now)+'-'+combobox2.text+'-'+combobox3.text+#32
簡單辦法就是吧日期存為文本格式﹐然后這樣寫sql,比如 一個日期字段為mydateselect * from table1 where mydate = '''+Trim(combobox2.text)+'''其中combobox2為用戶選擇的日期
ComboBox2是月分,ComboBox3是每月日期, 这个可以用datatimepicker 来替代。数据库中如果有时间这个记录就可以查,select * from table where time = datatimepicker.data;
我刚好以前有做过一个,不过我是用edit做的年\月,还能查另一个字段呢 sqlstr:='select * from 表名 where year(yfkdate)='#39+edit1.text+#39' and month(yfkdate)='#39+edit2.text+#39''; sqlstr:=sqlstr+' and rtrim(name)='#39+edit3.text+#39' order by yfkdate'; adoquery1.Close; adoquery1.SQL.Clear; adoquery1.SQL.Add(sqlstr); adoquery1.Open; 供参考
ComboBox2、ComboBox3为什么不合并在一起显示呢?
sqlstr:='select * from 表名 where year(yfkdate)='#39+edit1.text+#39' and month(yfkdate)='#39+edit2.text+#39'';
sqlstr:=sqlstr+' and rtrim(name)='#39+edit3.text+#39' order by yfkdate';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlstr);
adoquery1.Open;
供参考