如何判断?
我POST后现在执行TTABLE的LAST,可总是取不到新加的内容

解决方案 »

  1.   

    append之后
    好像会把新插入的这条记录作为当前的活动记录,直接调用fieldbyname().value 就可以取得
    该记录的字段值吧
    一下是help里面关于append的说明:
    Adds a new, empty record to the end of the dataset.procedure Append;DescriptionCall Append to:-->1 Open a new, empty record at the end of the dataset.
    -->2 Set the active record to the new record.After a call to Append, an application can enable users to enter data in the fields of the record, and can then post those changes to the database using Post (or ApplyUpdates if cached updating is enabled). A newly appended record is posted to the database in one of three ways:For indexed Paradox and dBASE tables, the record is inserted into the dataset in a position based on its index.
    For unindexed Paradox and dBASE tables, the record is added to the end of the dataset.
    For SQL databases, the physical location of the appended record is implementation-specific. For indexed tables, the index is updated with the new record information.
      

  2.   

    1.post后应再加updaterecord;(好象这么写,忘了)
    2.再都一次变量好了
      

  3.   

    用ACCESS,append之后不会把新插入的这条记录作为当前的活动记录 
      

  4.   

    用updaterecord,出错“dataset not in edit or insert mode”
      

  5.   

    用记录集,添加后MoveLast就行了。
      

  6.   

    我已经用了LAST,还是不行另外dadixiongxin(daxiong) ,我以前用ADO的时候,的确是这样的,但现在由于某种原因需要用BDE,用TABLE连,他总是不把这条记录作为当前记录。大家可看
    http://www.csdn.net/expert/topic/111/111753.shtm,是我在BCB组里的问题
      

  7.   

    我估计你的Last后,找不着当前记录 是记录排序造成的。
    你的库总有个关键字吧。
    Table.Post;
    Table.Findkey([关键字]);
      

  8.   

    可以根据关键字用locate()得出。
      

  9.   

    我现在是A,B两个表,A的主关键字是自增字段ID,B的主关键字是ID,现在A中每增加一条记录,B也相应的增加一条,而且要求B的ID和A的ID相同,A中所有其他字段组合起来都无法唯一确定一条记录
      

  10.   

    用Append应该最后一条纪录就是刚加的,你的问题是现在最后一条不是你刚加的吗?贴出你的部分源码看看!再有把你要实现的功能说详细一些。
      

  11.   

    //往第一个表中增加记录
            dm->Table1->Append();
            dm->Table1->FieldByName("root")->Value=-1;
            dm->Table1->FieldByName("title")->Value=title;
            dm->Table1->FieldByName("author")->Value=author;
            dm->Table1->FieldByName("time")->Value=StrToDate(ptime);
            dm->Table1->Post();
    //        dm->Table1->UpdateRecord();        sql="select * from "+Form1->TreeList1->Selected->Text;
            sql=sql+"data where 1=2";
            dm->adsImpcon->Active=false;
            dm->adsImpcon->CommandText=sql;
            dm->adsImpcon->Active=true;
            dm->adsImpcon->Append();
    //        dm->Table1->Refresh();
            dm->Table1->Last();
            dm->Table1->Next();//往第二个表中增加记录
            int aaa=dm->Table1->FieldByName("id")->AsInteger;
            dm->adsImpcon->FieldByName("id")->Value=aaa;
            dm->adsImpcon->FieldByName("content")->Value=addFile->Text;
            dm->adsImpcon->Post();
      

  12.   

    如果表的主关键字是自增字段ID,则新加的记录一定在最后,除非你使用了其它字段索引或ORDER BY,不然一般用LAST可以找到,如果不行,把TABLE CLOSE再OPEN应该可以了。
      

  13.   

    同意Raptor(猛禽),APPEND()后CLOSE()再OPEN()应该可以的 
      

  14.   

    我有个最为笨的又最为实用的方法,就是在表中添加一个自动增量字段"ID",那么你每次添加了新记录时,只要查找ID值最大的就行了。
      

  15.   

    从贴的源码看,Table1的操作应该没问题,当然,Last、Next是多余的。问题应该出那个adsImpcon上。
      adsImpcon是什么元件?是TClientDataset?如果是,是远程数据库连接,还是本地表?如果是本地表,不能使用CommandText属性查询;如果是Midas远程数据操作,在adsImpcon->Post后,应该使用adsImpcon->ApplyUpdates(-1);
      

  16.   

    我POST后现在执行TTABLE的LAST,可总是取不到新加的内容 你应该对自增字段ID进行一下从新排序。
      

  17.   

    在我用xbase数据库时,发现数据并没有被真正存储到硬盘上,而是在
    bde的缓存中,即使post也没有用。我们当时是用bde的api解决这个问题,在
    table的afterpost中调用dbiSaveChange(?),让数据真正写入。不知道对你是否有
    帮助。
      

  18.   

    raider98(白水) 请到
    http://www.csdn.net/expert/topic/111/111753.shtm