tomHanks
asked on
TDate
I am trying to input a date into an access db.
I have the following which doesn't work:
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO table1 (field,intfield,datefield) VALUES (:FIELD, :INTFIELD, :DATEFIELD)');
Parameters.ParamByName('FI ELD').Valu e := QuotedStr(edit1.text);
Parameters.ParamByName('IN TFIELD').V alue := 10;
Parameters.ParamByName('DA TEFIELD'). DataType := ftDate;
Parameters.ParamByName('DA TEFIELD'). Value := '20021010';
ExecSQL;
end;
I get this error:
-------------------------- -
Debugger Exception Notification
-------------------------- -
Project Project1.exe raised exception class EOleException with message 'Application uses a value of the wrong type for the current operation'. Process stopped. Use Step or Run to continue.
-------------------------- -
OK Help
-------------------------- -
Any ideas what I have to fix?
I have the following which doesn't work:
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO table1 (field,intfield,datefield)
Parameters.ParamByName('FI
Parameters.ParamByName('IN
Parameters.ParamByName('DA
Parameters.ParamByName('DA
ExecSQL;
end;
I get this error:
--------------------------
Debugger Exception Notification
--------------------------
Project Project1.exe raised exception class EOleException with message 'Application uses a value of the wrong type for the current operation'. Process stopped. Use Step or Run to continue.
--------------------------
OK Help
--------------------------
Any ideas what I have to fix?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
u need to do the foloving
var dat:tdatetime;
begin
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO table1 (field,intfield,datefield) VALUES (:FIELD, :INTFIELD, :DATEFIELD)');
Parameters.ParamByName('FI ELD').Valu e := QuotedStr(edit1.text);
Parameters.ParamByName('IN TFIELD').V alue := 10;
Parameters.ParamByName('DA TEFIELD'). DataType := ftString;
Parameters.ParamByName('DA TEFIELD'). Value := strtodate('mm/dd/yyyy'); //or what ever is your comuter date format (not sql date format)
ExecSQL;
end;
end;
u see the computer date format
with the
label1.caption:=datetostr( date);
:)
var dat:tdatetime;
begin
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO table1 (field,intfield,datefield)
Parameters.ParamByName('FI
Parameters.ParamByName('IN
Parameters.ParamByName('DA
Parameters.ParamByName('DA
ExecSQL;
end;
end;
u see the computer date format
with the
label1.caption:=datetostr(
:)
Tom Hanks! I'm your great fan... ;)
FormatDateTime('yyyy-mm-dd ', TDate);
ASKER