with I_test do
        begin
                close;
                ParamByName('allow').AsString:=sIP;
                prepare;
                try
                        execsql;
                except
                        showmessage('ERROR!');
                        exit;
                end;
        end;
        with Qry_ip do
        begin
                close;
                ParamByName('allow').AsString:=sIP;
                Open;
                if recordcount=0 then
                begin
                        showmessage('本机不允许执行这个程序!');
                        Application.Terminate;
                end;
        end;
这是我程序中的的一段,本意只是用Qry_ip查询本机ip是不是在表table1的allow这个列中,如果在其中,则允许执行,不在其中则不允许。但无论如何就是查询不出结果,所以无奈之下加了个I_test,用于测试一下数据是否准确。
qry_ip和I_test的语句是这样的
qry_ip:
select *
from table1 a
where a.program='ABC'
and a.allow=:allowI_test:
insert into table1
select 'ABC',null,:allow,null
from dual
执行以后,I_test执行成功,table1里面多了一条正确的纪录,里面的allow也是本机地址,但是Qry_ip这里通不过了,recordcount=0,不知道这是怎么回事,各位大大指点指点?

解决方案 »

  1.   

    不会的,只是一个字符串而已
    肯定使你处理的有不对的地方
    你把        with Qry_ip do
            begin
                    close;
                    ParamByName('allow').AsString:=sIP;
                    Open;
                    if recordcount=0 then
                    begin
                            showmessage('本机不允许执行这个程序!');
                            Application.Terminate;
                    end;
    拿到with Itest外部
      

  2.   

    看看你的ParamByName 'allow' 的类型是什么
      

  3.   

    谢谢各位,问题已经解决了,问题出在数据库那边,数据库那边的allow多了一个空格,但我用pl/sql developer来查询的时候developer对这个空格不敏感,所以被误导了。