update 入库 set 库存=:newkuchun where 货号=:货号以上就是通过adocommand来做操作的语句,可以运行通过,但就是库存里的值不是newkuchun的值。不知道那里有问题,

解决方案 »

  1.   

    中文没问题啊,在 select 和 insert 语句的时候都是可以用的啊,没听说过不能用中文吧,下面是代码
                adocommand1.ConnectionString:=constr;
                adocommand1.CommandText:='update 入库 set 库存=:newkuchun where 货号=:货号';
                adocommand1.Parameters.ParamByName('newkuchun').Value:=newkuchun;
                adocommand1.Parameters.ParamByName('货号').Value:=huohao;
                adocommand1.CommandType:=cmdtext;
                adocommand1.Execute;
                messagebox(0,pchar('记录已经成功修改!'),pchar('恭喜'),0);
    代码好像也看不出有什么问题,主要是可以运行,也提示 成功修改,可数据库里就是没有更新数值。
      

  2.   

    设断点或者showmessage,看看参数传的对不对吧.
      

  3.   

    调试时运行到  adocommand1.Parameters.ParamByName('货号').Value:=huohao;  时
     
     huohao这个变量的值也的确是变成了想要的正确值,再往下也能正常运行完。可数据库里的还是没更新,真是头大。 有那位高手能不能看出问题在那儿啊。我是没没办法了。
      

  4.   

    update 入库 set 库存=:newkuchun where 货号=:货号 
    货号=:货号    货号=货号 
      

  5.   

    刚才还又去查了 sql语句手册,语句没错啊,咋就不能更新呢。
      

  6.   

    constr指向的库和lz所查的库难道不一致......
      

  7.   

    where 货号=:货号'=:改为 =   后面的才是判断.
      

  8.   

    查询的库是一定的,这个没错,事件探查器是什么东东呀,没用过,我用的是delphi7,不知有没有哟,
      

  9.   

    如果用的MS SQLSERVER, 就有一个事件探查器的程序, 可以跟踪SQL server执行了什么SQL语句。
      

  10.   

    晕死,刚才用2007来试了下,把上面的代码复制过去,可以,成功了。数据库里的值也变成想要的了。天啊,真是郁闷,总不能让我用2007再写吧。东西都没改的,只是把相对应的edit改了下。
      

  11.   

    2007调试的代码      huohao:=strtoint(edit1.Text);
          kuchun:=strtoint(edit2.Text);
          huanhuoshuliang:=strtoint(edit3.Text);
          newkuchun:=kuchun-huanhuoshuliang;
          if newkuchun >= 0 then
            begin
                adocommand1.ConnectionString:=abc;
                adocommand1.CommandText:='update 入库 set 库存=:newkuchun where 货号=:货号';
                adocommand1.Parameters.ParamByName('newkuchun').Value:=newkuchun;
                adocommand1.Parameters.ParamByName('货号').Value:=huohao;
                adocommand1.CommandType:=cmdtext;
                adocommand1.Execute;
                messagebox(0,pchar('记录已经成功修改!'),pchar('恭喜'),0);
    跟7里面的一样,只有几个edit变了。
      

  12.   

    实在不好意思,找到问题了,没仔细检查,有个edit 号错了。谢谢大家了。大家都有分拿。