D6+ACCESS数据库
CurDate为短日期型:如:2003-2-30
CurTime为长时间型:如:10:10:00
可运行到下面过程时,出现错误:(无效的日期时间格式(NULL))
怎么回事?救命。
procedure TFrmMain.AddRecToDB(sCardID: string; TimeStage: Integer);
begin
with DM.CheckInfo do
begin
SQL.Text := 'INSERT INTO Empl_Check(User_ID,CurDate,CurTime,Type) '
+ 'VALUES(:ValID, :ValDate, :ValTime, :ValType)';
ParambyName('ValID').DataType := ftString;
ParamByName('ValDate').DataType := ftDate;
ParamByName('ValTime').DataType := ftTime;
ParamByName('ValType').DataType := ftInteger; ParamByName('ValID').AsString := sCardID;
ParamByName('ValDate').AsDate := date();
ParamByName('ValTime').AsTime := Time();
ParamByName('ValType').AsInteger := TimeStage; ExecSQL;
end;
end;
CurDate为短日期型:如:2003-2-30
CurTime为长时间型:如:10:10:00
可运行到下面过程时,出现错误:(无效的日期时间格式(NULL))
怎么回事?救命。
procedure TFrmMain.AddRecToDB(sCardID: string; TimeStage: Integer);
begin
with DM.CheckInfo do
begin
SQL.Text := 'INSERT INTO Empl_Check(User_ID,CurDate,CurTime,Type) '
+ 'VALUES(:ValID, :ValDate, :ValTime, :ValType)';
ParambyName('ValID').DataType := ftString;
ParamByName('ValDate').DataType := ftDate;
ParamByName('ValTime').DataType := ftTime;
ParamByName('ValType').DataType := ftInteger; ParamByName('ValID').AsString := sCardID;
ParamByName('ValDate').AsDate := date();
ParamByName('ValTime').AsTime := Time();
ParamByName('ValType').AsInteger := TimeStage; ExecSQL;
end;
end;
ParamByName('ValID').AsString := sCardID;
不对,
首先为了适应你的‘2003-2-30’要定义LongDateFormat:= 'yyyy-m-d';
ParamByName('ValID').Value := StrToDate(sCardID);
ParamByName('ValDate').Asstring := datetimetostring(date());
ParamByName('ValTime').Asstring := datetimetostring(Time());
顺便再问一下:
由用户在DATETIMEPICKER中选择两个天数,然后从数据库中得到在这两个日期之间的所有记录。应怎么办呢?
有哪位高手对时间日期这方面弄得比较清楚的,望不吝赐教,我都被搞晕了。