我是C#的新手,現在我完全陷入這個函數。 任何幫助,將不勝感激。C#OutOfMemoryException數組
我得到一個OutOfMemoryException mess.Add(firstname);
我敢肯定,這是因爲數組故障,但我似乎無法使其工作。
誰能以正確的方式引導我?
這是我到目前爲止的代碼:
public List<string> SelectEmployee(string pkrelation)
{
SDKRecordset inboundSet = IQSDK.CreateRecordset("R_CONTACT", "", "FK_RELATION = " + pkrelation, "");
inboundSet.MoveFirst();
string person = inboundSet.Fields["FK_PERSON"].Value.ToString();
messages.Add(person);
inboundSet.MoveNext();
SDKRecordset inboundSet2 = IQSDK.CreateRecordset("R_PERSON", "", "PK_R_PERSON = " + person, "");
if (inboundSet2 != null && inboundSet2.RecordCount > 0)
{
inboundSet2.MoveFirst();
do
{
string firstname = inboundSet2.Fields["FIRSTNAME"].Value.ToString();
mess.Add(firstname);
inboundSet.MoveNext();
}
while (!inboundSet2.EOF);
return mess;
}
messages.Add("Error, didn't work.");
return messages;// null;
出於好奇,「inboundSet2」中有多少條記錄?你確定'EOF'在經過合理次數的迭代之後被擊中了嗎?編輯:你有一個錯字嗎?不應該是'inboundSet2.MoveNext()',而不是'inboundSet.MoveNext()'? –
在這種情況下,看看它是否適用於非常小的記錄集,如10和10.如果出現錯誤* still *,則清楚地處理了從不退出或類似的循環。 #basictroubleshooting – catfood
什麼是'混亂'?和'messages'一樣嗎?你在某處清理它嗎? – JeffRSon