请教大家,在客户端执行一个按钮事件时,有些客户端上会提示 invalid datetime:'2007-6-27' 错误,而有些电脑上没问题,这是怎么回事??? 按钮事件代码如下: if dm.A_jiesuan_cx.Active then dm.A_jiesuan_xz.Close; dm.A_jiesuan_xz.SQL.Clear; dm.A_jiesuan_xz.SQL.Add('select * from xlx08,xlx02 where xlx0808=0 and xlx0202=xlx0804 and xlx0801='''+DBEditEh2.Text+''' '); dm.A_jiesuan_xz.Open; if dm.A_jiesuan_xz.RecordCount>0 then begin jiesuan_xz.Edit1.Text:=dm.A_jiesuan_xz.FieldValues['xlx0804']; jiesuan_xz.Edit2.Text:=dm.A_jiesuan_xz.FieldValues['xlx0203']; jiesuan_xz.Edit3.Text:=dm.A_jiesuan_xz.FieldValues['xlx0801']; jiesuan_xz.Edit4.Text:=dm.A_jiesuan_xz.FieldValues['xlx0802']; jiesuan_xz.Edit5.Text:=dm.A_jiesuan_xz.FieldValues['xlx0806']; jiesuan_xz.Edit6.Text:=dm.A_jiesuan_xz.FieldValues['xlx0805']; jiesuan_xz.Edit9.Text:=dm.A_jiesuan_xz.FieldValues['xlx0809']; jiesuan_xz.ComboBox1.Text:=dm.A_jiesuan_xz.FieldValues['xlx0807']; jiesuan_xz.ComboBox2.Text:=dm.A_jiesuan_xz.FieldValues['xlx0803']; jiesuan_xz.ComboBox3.Text:=dm.A_jiesuan_xz.FieldValues['xlx0813']; jiesuan_xz.Edit7.Text:=dm.A_jiesuan_xz.FieldValues['xlx0812']; jiesuan_xz.DBDateTimeEditEh1.Text:=dm.A_jiesuan_xz.FieldValues['xlx0814']; jiesuan_xz.DBDateTimeEditEh2.Text:=dm.A_jiesuan_xz.FieldValues['xlx0815']; jiesuan_xz.Edit8.Text:=dm.A_jiesuan_xz.FieldValues['xlx0816']; jiesuan_xz.Edit10.Text:=dm.A_jiesuan_xz.FieldValues['xlx0217']; jiesuan_xz.Edit11.Text:=dm.A_jiesuan_xz.FieldValues['xlx0218']; jiesuan_xz.Edit12.Text:=dm.A_jiesuan_xz.FieldValues['xlx0219']; jiesuan_xz.Edit13.Text:=dm.A_jiesuan_xz.FieldValues['xlx0817']; jiesuan_xz.Edit14.Text:=dm.A_jiesuan_xz.FieldValues['xlx0818']; jiesuan_xz.Edit15.Text:=dm.A_jiesuan_xz.FieldValues['xlx0226']; jiesuan_xz.Edit16.Text:=dm.A_jiesuan_xz.FieldValues['xlx0227']; jiesuan_xz.Edit17.Text:=dm.A_jiesuan_xz.FieldValues['xlx0819']; IF dm.A_jiesuan_xz.FieldValues['xlx0223']='0' then begin jiesuan_xz.CheckBox2.Checked:=false; end else begin jiesuan_xz.CheckBox2.Checked:=true; end;
----------------------------------------------
-
Here, we can see the three parts of the problem: 1) user input;
2) how the code consumes the data;
3) how data is stored in the DB;
In this way, it is interesting to standardize input, consumption and consultation.
So, you can take as a reference how the date is stored in the DB, or create a procedure to analyze the data input and carry out the query as expected in the DB, and vice versa
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
1) TFormatSettings.FORMATSETTING = is global in Delphi
2) you can create a "TFormatSettings" variable to use without compromising it globally in your code!
var SF : TFormatSettings; ... MyDateTime := StrToDateTime( 'xxxxxx', SF ); .... Initialization // or in any other section in your code etc... SF:= TFormatSettings.Create('.....'); SF.xxxxxxxxx := zzzzzzzz;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3