2017-09-11 123 views
0

在我的表單中,我在DataSource中使用了一個臨時表 - 與屬性TableType:InMemory如何在臨時表中插入第二條記錄?

在我的形式我有一個簡單的代碼,就像這樣:

public TableTmpTable insertRecords(String _param_I, string _param_II) 
{ 
    TableTmpTable myInMemoryTable; 

    myInMemoryTable.clear(); 
    myInMemoryTable.initValue(); 

    myInMemoryTable.Field_I = _param_I; 
    myInMemoryTable.Field_II = _param_II; 

    myInMemoryTable.insert(); 

    return myInMemoryTable; 
} 

我需要調用此方法不止一次。

但是,當我打電話的方法,我失去了我以前的記錄。 如何在不同的時間在InMemory表中插入更多記錄?

感謝您的建議!

回答

2

範圍

被插入在第一個記錄時InMemory表被實例化。僅在引用表的記錄緩衝區變量存在時,實例化的InMemory表纔會繼續存在。 InMemory表的內存或磁盤空間在記錄緩衝區超出範圍時立即解除分配。

從MSDN,Temporary InMemory Tables

你的代碼確實是什麼創建表的一個新實例的方法被調用的時間緩衝。相反,您需要使用表單數據源的表緩衝區。

又見Temporary table as form data sourceAX 2012: Using Temporary Table as Form’s Datasource

+0

Thanks @ FH-Inway。非常有用的建議。 我只在Form的classDeclaration my Table中聲明瞭InMemoryTable一次,並在所有進程中使用它。 – ulisses

0

只是分割你的方法一到兩年。

第一種方法將初始化您的表格,第二種方法將插入您的記錄。

+0

OP在評論中提到,她在窗體的classDeclaration中初始化表。除此之外,您的初始化方法還會做什麼? –

相關問題