我用ADOQuery与DbGrid显示表中的记录,为什么当表中的没有记录时就报错,“invalid variant type conversion”

                            
我的代码如下:   
    str1:='select   Goods.G_Class   as   C_Code1,Goods.G_Code   Code1   ,Goods.G_Name     GName1,Goods.G_GuiGe   GuiGe1   ,Class.C_Name   CName1,Goods.G_DanWei   DanWei1,Goods.G_Min   min1,Goods.G_Max   max1,     ';  
      str2:='round(Goods.G_Num,2)   Num1,round(Goods.G_Jia,2)   Jia1,round(Goods.G_Amount,2)   Amount1   ';  
  str3:='from   Goods,Class   where   Goods.G_Class=Class.C_Code   and   Class.C_Name='''+trim(cmtcom1.text)+'''';  
  end;  
  str1:=str1+str2+str3;  
  cmttable1.Close;  
  cmttable1.SQL.Clear;  
  cmttable1.SQL.Add(str1);  
  cmttable1.Open;   Pdata.Classstr:='';  
            Pdata.classstr:=cmttable1.fieldbyname('C_Code1').value;  
  end;  
  dbgrid1.Columns[0].FieldName:='Code1';  
  dbgrid1.Columns[1].FieldName:='GName1';  
  dbgrid1.Columns[2].FieldName:='GuiGe1';  
  dbgrid1.Columns[3].FieldName:='CName1';  
  dbgrid1.Columns[4].FieldName:='DanWei1';  
  dbgrid1.Columns[5].FieldName:='min1';  
  dbgrid1.Columns[6].FieldName:='max1';  
  dbgrid1.Columns[7].FieldName:='Num1';  
  dbgrid1.Columns[8].FieldName:='Jia1';  
  dbgrid1.Columns[9].FieldName:='Amount1';

查看回复

相关问题