0
的所有recors在以下代碼中,我希望只讀取一次數據集記錄以避免數據庫事務,並且希望按照第一行迭代循環。按照第一行迭代Foreach循環以獲得表
//InitializeConfig method return dataset which contains 6 records
// i.e. Table with 6 rows and 6 columns
dsConfig = objConfig.InitializeConfig(objConfig, NoOfGates);
foreach (DataRow dr in dsConfig.Tables[0].Rows)
{
objCR.GetCard(objConfig.iIndex, objConfig.iCRNo, out MainId);
}
但我總是從第一行開始只記錄每次迭代的記錄。
這裏我只想從數據集中讀取記錄一次,並希望徹底使用它。 –
你的問題和你的代碼對我來說不清楚,但我注意到你沒有在'foreach'循環中的任何地方使用'dr'。 – venerik
試試這個:foreach(DataRow dr in dsConfig.Tables [0] .AsEnumerable()) – jdweng