sql:='select * from ComboDetail where comboID='+ (sender as TwwDBComboBox).HelpKeyword ;//此句生成的sql决对没有问题
  FileDataMD.qrytmp2.Close;
  FileDataMD.qrytmp2.SQL.Text:=sql;
  FileDataMD.qrytmp2.Open;当执行最后一句时出现“项目在所需的名称或序数中未被发现”,请问这是什么原因引起的呀?应该如何解决?

解决方案 »

  1.   

    你跟踪一下sql到底是什么,肯定是这句sql语句的问题。
      

  2.   

    sql 没问题
    select * from combodetail where comboid=2    这句没问题
      

  3.   

    ---------------------------
    Debugger Exception Notification
    ---------------------------
    Project zyfile.exe raised exception class EVariantError with message 'Invalid variant type conversion'. Process stopped. Use Step or Run to continue.请问上面的是由什么大原因引发的异常?  FileDataMD.qrytmp2.Close;
      FileDataMD.qrytmp2.Open;
    就是执行上两句出现的。
      

  4.   

    select * from combodetail where comboid=2    这句没问题
    --------------------------------------------------------
    这个当然没问题啦。
    sql:='select * from ComboDetail where comboID='+ (sender as TwwDBComboBox).HelpKeyword ;//但是这句有问题吧。
    试试
    sql:='select * from ComboDetail where comboID='''+ (sender as TwwDBComboBox).HelpKeyword+'''' ;
      

  5.   

    Project zyfile.exe raised exception class EVariantError with message 'Invalid variant type conversion'. Process stopped. Use Step or Run to continue.
    -------------------------------------------------------------------------
    HelpKeyword
    你的字段类型对吗?
      

  6.   

    调试的时候
    sql:='select * from ComboDetail where comboID='+ (sender as TwwDBComboBox).HelpKeyword ;//但是这句有问题吧。
    -----------------------------------------------------
    中得到的sql就是
    select * from combodetail where comboid=2    这句没问题字段类型也是正确的,因为我在SQL Server查询分析器中都测试过了
      

  7.   

    Project zyfile.exe raised exception class EVariantError with message 'Invalid variant type conversion'. Process stopped. Use Step or Run to continue.请问上面的是由什么大原因引发的异常?  FileDataMD.qrytmp2.Close;
      FileDataMD.qrytmp2.Open;
    就是执行上两句出现的。
    ================================================
    你是不是在关闭或者打开的相关事件里做了什么动作?
      

  8.   

    对了,有一点很重要的还没有问清楚,你说的那个到底是本地代码错误还是数据库sql查询出错?
    就是说错误的类型是什么?
      

  9.   

    shit!不留意进错了,我不是高手,当我什么都没有说过.
      

  10.   

    (sender as TwwDBComboBox)//这句什么意思?sender 是字段名吗?
      

  11.   

    sql查询没错
    是代码执行出错
      

  12.   

    (sender as TwwDBComboBox)//这句什么意思?sender 是字段名吗?-------------------
    sender不是字段名
    上句的意思是将sender转换成TwwDBComboBox类型
      

  13.   

    你是用什么连接数据库的,BDE还是ADO,是不是要关心一下qrytmp2的连接?
      

  14.   

    楼主听好了,
    按照你说的这个情况,SQL语句本身是不会错的,那么情况出现在,qrytmp2作了别的用途就是说你一定用qrytmp2连接了别的datasource,连接用于显示dbgrid,dbedit等数据感知控件了,这样,你一改变查询的数据集,结果呢。会出现“序数错误”。使用datamodule而又不注意命名的话,很容易发生这样的事情,你最好新建一个
    如qrytmp3再试,绝对解决此问题。以后注意啊,如果用于数据感知的数据集,你可以加后缀来区别。。
    =======================
    希望能解决你的问题。