我的程序运行后出错,提示如下,是什么意思?
Progect progect1.exe raised exception class EVarianTypeCastError with messge 'Could not convert variant of type (null) into type(string)'
Process stopped.
请问这是什么意思啊??

解决方案 »

  1.   

    不能将null转为string把你数据库里取出的值不要用xxxtostr()函数转换用fieldbyname('xxx').asstring方式自动转换
    或者 if not table1.fieldbyname.isnull then  xxxtostr(...)判断
      

  2.   

    我是用的fieldbyname().asstring方式啊.程序运行到
    application.creatform(tform1,form1);
    时出现错误的.并且要连续按三次运行才能跳过错误,就不知道是怎么回事,急死了
      

  3.   

    在你的form1.oncreate事件中有什么代码?
      

  4.   

    里面没什么代码。出错的地方在下面的程序里:
    program Project1;uses
      Forms,
      DataModule in 'DataModule.pas' {DM: TDataModule},
      Unit1 in 'Unit1.pas' {Form1},
      Unit2 in 'Unit2.pas' {Form2};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TDM, DM);
      Application.CreateForm(TForm1, Form1);(出错)
      Application.Run;
    end.
      

  5.   

    ...如果formcreate里面有错误代码一样会停到这里
      

  6.   

    jinjazz(三个小时上下班),我晕啊
    我重新试了一个小程序,建了一个datamodule,程序运行后也是提示这种错误 啊unit Unit1;interfaceuses
      SysUtils, Classes, DB, ADODB;type
      TDataModule1 = class(TDataModule)
        ADOTable1: TADOTable;
        ADOConnection1: TADOConnection;
        ADOTable2: TADOTable;
        ADOTable3: TADOTable;
        DataSource1: TDataSource;
        DataSource2: TDataSource;
        DataSource3: TDataSource;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      DataModule1: TDataModule1;implementation{$R *.dfm}end.然后在progect1中就提示有错了program Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {DataModule1: TDataModule};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TDataModule1, DataModule1);
      Application.Run;//(到这时错)***
    end.