关于';'expected but'.'found的错误
我按书上写的设置了几个组件,参数如下
Table的DatabaseName为DBDEMOS,TableName为指定数据库,Active为True,把DataSource的DataSet设为Table1,把DBNavigator和DBGrid的DataSource设为DataSource1对数据源的OnStateChange编写如下代码:case DataSource1.DataSet.State of
dsBrowse : Caption :='Browse';
dsEdit : Caption :='Edit';   
dsInsert : Caption:='Insert';  
else
Caption:='Other State';可一运行就出现如下错误:
[Error]Unit1.pas(39):';'expected but'.'found
[Error]Unit1.pas(41):Declaration expected but end of file found
[Fatal Error]Project1.dpr(5):Could not compile used unit 'Unit1.pas'我将人为添加的
case DataSource1.DataSet.State of
dsBrowse : Caption :='Browse';
dsEdit : Caption :='Edit';   
dsInsert : Caption:='Insert';  
else
Caption:='Other State';
一删除,程序就能运行,也就是说问题出在这几行代码上了,可我实在是看不明白人家的错误提示,请高手讲解一下系统给出的错误提示是什么意思,我的代码应当如何改,谢谢了。

解决方案 »

  1.   

    else前面的语句不加 分号 的
    dsInsert : Caption:='Insert';  //把这个分号删除
      

  2.   

    else前面的语句不加 分号 的
      

  3.   

    Error]Unit1.pas(39):';'expected but'.'found   ----所指为找不到‘;’,一般是因为少写或者匹配不对所致,这里是因为else前面的语句加了分号 [Error]Unit1.pas(41):Declaration expected but end of file found ----所指为文件尾已到,但缺少声明,这里的原因和上面相同[Fatal Error]Project1.dpr(5):Could not compile used unit 'Unit1.pas' ----所指为不能编译单元文件'Unit1.pas'
      

  4.   

    唉........依我之见,你是 写了case 没写与case配对的end 了吧。。case语句必须要end配对的。case * of
      case1: **;
      case2: **;
    ……
      casen: **;
      else **
    end;