我是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