var
var   
studno:Integer;
begin
studno:=strtoint(edit1.text);
datamodule9.Query1.SQL.Clear;
datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='''+studno+'''');
                                ^^^Studno是数字,怎么能进行字符相加。直接换Edit1.Text不就行了
datamodule9.Query1.Open;

解决方案 »

  1.   

    除非你的EDIT1。TETX中輸入的是0~9的字符否則如“SAFSDAF”肯定出錯三後者是CSTRING類它不能轉化成INT的喲怎麼樣說對否?
      

  2.   

    但是我的数据库中studentNo是定义为数字型的
    如直接用edit1.text
    也出错,数据类型不一样
      

  3.   

    既然是数字型就不要加引号:
    var
    studno:Integer;
    begin
    datamodule9.Query1.SQL.Clear;
    datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='+edit1.text);
    datamodule9.Query1.Open;
    end;
      

  4.   

    datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='''+studno+'''');
    studno不是字符型,用不着'''
    这样写我想应该可以:
    datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='+inttostr(studno)+);
      

  5.   

    datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='''+studno+'''');
    studno不是字符型,用不着'''
    这样写我想应该可以:
    datamodule9.Query1.SQL.Add('select bookid,borrowtime,returntime,delayed from borrowrecord where studentNo='+inttostr(studno));