在一个DBGRID中可以打开几个表,在表中有几个里都有为时间类型的列。
列号不同。
如何在保存前判断修改过的值是否为日期类型
不是则报错。

解决方案 »

  1.   

    简单一点吧:
    try
      StrToDate('日期');
    except
      showmessage('错!');
    end;
      

  2.   

    var v_date:Tdatetime;
    try 
      v_date:=strtodatetime(text);
    except
      showmessage('error');
    end
      

  3.   

    try
      StrToDate('日期');
    except
      showmessage('错!');
    end;
      

  4.   

    同意上面用try except end;
    数据库应该也会自动报错,不过跳出个东西来总是不好:)
      

  5.   

    借用一下
    try
      StrToDate('日期');
    except
      showmessage('错!');
    end;
      

  6.   

    try
      StrToDate('日期');
    except
      showmessage('错!');
    end;
      

  7.   

    Function TFra_Show.IsDate(TmpDate:String):Boolean;
    var
      ADate: TDateTime;
    Begin
        Try
            ADate:=StrToDate(TmpDate);
            Result:=True;
        except
            ReSult:=False
        end;end;
      

  8.   

    try
      StrToDate('日期');
    except
      showmessage('错!');
    end;
      

  9.   

    这个我也懂了
    但我不知道判断为那个列,大家看看我下面写的那里不对
    {typearray是我定义的一个字符串内容为ccddmm这种类型,用来标记dbgrid中列的属性。c为字符串,d为时间,}
    var i:integer;
    day :tdatetime;
    begin
    i:=0;
    while i<=Length(typearray) do
    begin
     if typearray[i]='d' then
     begin
     try
     day:=strtodate(DBGrid1.Fields[i].value);
     showmessage(datetostr(day));
     showmessage('dd');
     except showmessage('aaaa');
     exit;
     end;
     end;
     i:=i+1;
    end;
      

  10.   

    strDate:=DBGrid1.DataSource.DataSet.Fields[1].asString;try
      StrToDate(strDate);
    except
      showmessage('错!');
    end;
      

  11.   

    当我在dbgrid中增加数值时,时间我输入了‘1999-1-2’
    当post时
    但DBGrid1.Fields[i].value为什么为空,
      

  12.   

    你的Options->dgRowSelect 属性设置为true
      

  13.   

    The user can select an entire row, as well as selecting individual cells. If Options includes dgRowSelect, dgEditing and dgAlwaysShowEditor are ignored.