正象你说的
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;

解决方案 »

  1.   

    要改回去,用Update就可以
    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;
      

  2.   

    多谢,我再问一下,我的语句是
    Sql.Add('select * from information where location='''+Edit_Location.Text+'''');
    其中有一个字段是Date型的,所以
    Edit_LogonTime.Text:=FieldByName('Logon_Time').Value;
    就报错了,怎么转化成string型的,再显示?
    或者直接显示Date型的数据也成,如何实现?
      

  3.   

    怎样将Oracle的Date类型转换成Delphi的string类型?
      

  4.   

    Edit_LogonTime.Text:=FieldByName('Logon_Time').Value;
    改成:
    Edit_LogonTime.Text:=FieldByName('Logon_Time').AsString;
      

  5.   

    不成,报错!!!
    Logon_Time是Date型的 比如:02-5-29 21:34:27
      

  6.   

    LononTime:TDatetime;
     logonTime:=Fieldbyname('Logon_Time').AsDatetime;
    Edit_LogonTime.Text:=FormatDatetime('YYYY-mm-dd',LogonTime);
      

  7.   

    不成,还是出错!
    Errors Occourred!!!
    为什么?
    是不是控件里需要什么设置?
      

  8.   

    如何将Oracle的Date型的字段数据转换成Delphi的string型,输出?
    比如:LogonTime字段,显示是02-05-29 12:23:23
    我要将他显示到Edit1.Text中,如何实现?
    以上方法老出错!!!
      

  9.   

    两种办法:
    (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;以后也不用再转换,
    很方便。
      

  10.   

    多谢,我一会去试试,成功的话就给分,分数不多也是一点心意!
    :)
    再有就是我在Oracle库中的两个日期类型的字段怎么做减法,然后得出一个整形的值呢?
      

  11.   

    oracle的data型字段支持日期运算。例如:
    select sysdate-1998-02-03 from dual;
    既如此,你的两列运算就行!你试一下吧。