DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: coooyang
今日帖子: 31
在线用户: 9
导航: 论坛 -> 数据库专区 斑竹:liumazi,waterstone  
作者:
男 fuhaijun725 (fuhaijun725) ★☆☆☆☆ -
普通会员
2007/8/8 16:32:32
标题:
错误提示 invalid datetime:'2007-6-27' 浏览:2045
加入我的收藏
楼主: 请教大家,在客户端执行一个按钮事件时,有些客户端上会提示 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;
----------------------------------------------
-
作者:
男 ghs_79 (ghs) ★☆☆☆☆ -
盒子活跃会员
2007/8/8 17:43:22
1楼: 日期格式的问题,
----------------------------------------------
Delphi爱好者。
作者:
男 doorkey (DoorKey) ★☆☆☆☆ -
盒子活跃会员
2007/8/8 19:59:15
2楼: 电脑的日期格式调整一下就可以了的。
----------------------------------------------
QQ: 9717005 我的Blog:http://www.cnblogs.com/anydelphi/
作者:
男 lsuper (lsuper) ★☆☆☆☆ -
盒子活跃会员
2007/8/9 10:54:08
3楼: 你是在 vista 下执行的吧
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/9/29 22:56:43
4楼: 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
作者:
男 ufo2003 (ufo) ★☆☆☆☆ -
普通会员
2023/9/29 23:23:29
5楼: 在程序窗体开始建立时加入如下代码进行时间日期格式的设置
procedure TShellForm.FormCreate(Sender: TObject);
begin
   DateSeparator := '-';
  TimeSeparator := ':';
  ShortDateFormat := 'yyyy-mm-dd';
  LongDateFormat  := 'yyyy-mm-dd';
  ShortTimeFormat := 'hh:nn:ss';
  LongTimeFormat  := 'hh:nn:ss';

end;
----------------------------------------------
delphi
作者:
男 lsuper (lsuper) ★☆☆☆☆ -
盒子活跃会员
2023/9/30 1:25:12
6楼: 固化格式,楼上正解 [点赞] ~

多年老帖被大佬们翻牌 [捂脸]
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/9/30 1:44:47
6楼: Remembering that:

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
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行62.5毫秒 RSS