正象你说的
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select studentcode ');
SQL.Add(' from information ');
SQL.Add(' where location=''1'' ');
Open;
Edit1.Text := FieldByName('studentcode').Value;
end;
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select studentcode ');
SQL.Add(' from information ');
SQL.Add(' where location=''1'' ');
Open;
Edit1.Text := FieldByName('studentcode').Value;
end;
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Update information ');
SQL.Add(' Set studentcode = :studentcode ');
SQL.Add(' where location=''1'' ');
ParamByName('studentcode').Value := Edit1.Text;
Prepare;
ExecSQL;
end;
Sql.Add('select * from information where location='''+Edit_Location.Text+'''');
其中有一个字段是Date型的,所以
Edit_LogonTime.Text:=FieldByName('Logon_Time').Value;
就报错了,怎么转化成string型的,再显示?
或者直接显示Date型的数据也成,如何实现?
改成:
Edit_LogonTime.Text:=FieldByName('Logon_Time').AsString;
Logon_Time是Date型的 比如:02-5-29 21:34:27
logonTime:=Fieldbyname('Logon_Time').AsDatetime;
Edit_LogonTime.Text:=FormatDatetime('YYYY-mm-dd',LogonTime);
Errors Occourred!!!
为什么?
是不是控件里需要什么设置?
比如:LogonTime字段,显示是02-05-29 12:23:23
我要将他显示到Edit1.Text中,如何实现?
以上方法老出错!!!
(1)select 时用oracle的转换函数:to_char(列名),即select col1,col2,
to_char(col3) as DD,....from ...;然后,Edit_LogonTime.Text:=
FieldByName('DD').AsString;
(2)把这个edit控件去掉,换上一个Tdatetimepicker控件,直接赋值:
datatimepicker1.date:=fieldbyname('col3').value;以后也不用再转换,
很方便。
:)
再有就是我在Oracle库中的两个日期类型的字段怎么做减法,然后得出一个整形的值呢?
select sysdate-1998-02-03 from dual;
既如此,你的两列运算就行!你试一下吧。