sql語句中日期插入錯誤,為什麼???怎麼改寫???date應該是系統日期吧!!!
sqlinst:='insert into tab_staff (sta_id,sta_name,dep_id,sta_note,modtime) ';
sqlinst:=sqlinst+'values('''+editsqlid.text+''','''+editsqlname.text+''',';
sqlinst:=sqlinst+ IntToStr(ComboBoxsql.ItemIndex)+','''+memosql.text+''' '+date+')';
sqlinst:='insert into tab_staff (sta_id,sta_name,dep_id,sta_note,modtime) ';
sqlinst:=sqlinst+'values('''+editsqlid.text+''','''+editsqlname.text+''',';
sqlinst:=sqlinst+ IntToStr(ComboBoxsql.ItemIndex)+','''+memosql.text+''' '+date+')';
sqlinst:=sqlinst+ IntToStr(ComboBoxsql.ItemIndex)+','''+memosql.text+''' '+date+')';
我按妳說的 date 改成DateToStr(date) 後,sql語句如下
單步調試見到sqlinst中modtime字段為
2001/1/18, 而查看MS SQL Server 7.0 的Enterprise Manager中插入的是1990/4/22日.
為什麼這麼奇怪呀???? sqlinst:='insert into tab_staff (sta_id,sta_name,dep_id,sta_note,modtime) ';