procedure Tlkform.Button1Click(Sender: TObject);
var i:integer;
begin
  i:=strtoint(edit2.Text);
  edit5.Text:=inttostr(i);
 with adoquery1 do
  close;
  adoquery1.SQL.clear;
  adoquery1.SQL.Add('select jc_id 入库编号,jc_state 进出仓类型,suppy_info.suppy_id 物料代码,suppy_name 物料名称,in_number 进仓数量,suppy_info.suppy_address 仓库名 from  jc_details,suppy_info');
  adoquery1.SQL.Add('where jc_id like i');
  adoquery1.Open;
  if adoquery1.RecordCount=0 then
  begin
  showmessage('该记录不存在');
  end;我的 jc_id 在数据库里是定义为int
为什么会出现错误“is not a vaild integer value“

解决方案 »

  1.   

      adoquery1.SQL.Add('where jc_id like i'); 
    为什么要用like? 到底想查什么结果? like 一般都字符类型常用 而且加'%'或'_'
    这样试下
    adoquery1.SQL.Add('where jc_id = :aa');
    parameters.parambyname('aa').value:=i;
      

  2.   

    楼主刚开始用delphi编程序吧, 更是刚开始在delphi中操作数据库哦;
    with adoquery1 do 
    close;      
    不如直接写成 adoquery1.close;
    select部分不如直接写成: adoquery1.sql.add('select * ... from ... where jc_id=' + inttostr(i));
    // 也没有必要使用 parameters...
      

  3.   

    这句代码的毛病
    adoquery1.SQL.Add('where jc_id like i'); 
     
    这句代码并没有将 变量 i 所代表的数值填入,而是直接加入了 字符"i" ,试想 ' where jc_id like i ' 中 jc_id 字段能等于 字符'i' 么?你可以采用如下方法(1) SQL.ADD(' WHERE jc_id =:tmp ');
        Parameters.ParamByName(tmp).Value := i;
    (2) 方法同上。
      

  4.   

    SQL语句写得不对,你的SQL中用到了两个表,但并没有说明两个表的关联关系,楼主应该先看看SQL的表联接查询
      

  5.   

    'select jc_id 入库编号,jc_state 进出仓类型,suppy_info.suppy_id 物料代码,suppy_name 物料名称,in_number 进仓数量,suppy_info.suppy_address 仓库名 from  jc_details LEFE JOIN suppy_info ON jc_details.字段=sippy_info.字段'); 
      adoquery1.SQL.Add('where 表.jc_id like '+inttostr(i));
      

  6.   

    帮你优化:
    至于你的数据库表是如何设计的,那我就不管了,SQL语句只供参考...
    至于你的SQL语句太长,所以三个来写,看你须要了...
    至于你的i,转来换去,在这里体现不出有什么特殊的用途,多余的...Procedure Tlkform.Button1Click(Sender: TObject);
    begin
     Edit5.Text:=edit2.Text;
     with adoquery1 do
      begin
       close;
       SQL.clear;
       SQL.Add('select A.jc_id 入库编号,A.jc_state 进出仓类型,B.suppy_id 物料代码,A.suppy_name 物料名称,A.in_number 进仓数量,B.suppy_address 仓库名 ');
       SQL.Add(' from  jc_details A Left join suppy_info B on A.字段=B.字段'); {字段就是两表的连接条件}
       SQL.Add(' where A.jc_id like ' + Trim(edit2.Text));   
       Open;
      if RecordCount=0 then
        showmessage('该记录不存在');
      end;
    end;
      

  7.   

    procedure Tlkform.Button1Click(Sender: TObject);
    var i:integer;
    begin
     i:=strtoint(edit2.Text);
      close;
      adoquery1.SQL.clear;
      adoquery1.SQL.Add('select jc_id 入库编号,jc_state 进出仓类型,suppy_info.suppy_id 物料代码,suppy_name 物料名称,in_number 进仓数量,suppy_info.suppy_address 仓库名 ');
      adoquery1.SQL.Add('from  jc_details LEFE JOIN suppy_info on jc_details.suppy_id=suppy_info.suppy_id');
      adoquery1.SQL.Add('where jc_id='+inttostr(i));
      //adoquery1.Parameters.ParamByName('aa').Value:= i;
      adoquery1.Open;
      if adoquery1.RecordCount=0 then showmessage('该记录不存在');
    end;上面各位的高手的方法已全部试用,但仍然有错~~~~~~我加分啊jc_id 是数据库里是整形的,在edit2.text里输入jc_id的值,然后查询~~~
      

  8.   

    你这样写着太乱
    'SELECT a.jc_id 入库编号,..... FROM jc_Details a LEFT JOIN suppy_Info b ON a....
      WHERE a.jc_id='+inttsotr(i);
    而且转换为int的时候尽量这么写
    i:=StrToIntDef(edit2.text,0);PS:另外错误提示是什么,你说清了别人才好帮你解决
      

  9.   

    “is not a vaild integer value“~~~错误提示
      

  10.   

    F7单步运行一下
    是到那一句就出错?“...is not a vaild integer value“ is 前面是什么,错误都不描述清楚一点????你的这些代码只有i 是 integer 类型的,不会第一句就出错了吧??i:=strtoint(edit2.Text); 
    如果edit2输入是字符或中文,也会有这样错误!!!
      

  11.   

    “...is not a vaild integer value“ is 前面是什么,错误都不描述清楚一点???? 
    回答:前面是二个单引号~~~按F7都可以执行~~
    edit2输入只是数字而已