# Why my GetTableRowNames failed?

**URL:** <https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, UE4, question, CPP\
**Created:** [August 13, 2022, 3:37pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748 "2022-08-13T15:37:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 13, 2022, 3:37pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/1 "2022-08-13T15:37:33Z")

</div>

Can anyone correct me What I am doing wrong here in this logic?

> if (MyRowNames\_Acc) //This fails, and why?

```auto
case EItemType::E_Accessories:
{
	if (const UDataTable* OutRowNames_Acc = LoadObject<UDataTable>(NULL, TEXT("/Game/DataTables/DT_WeaponAcc")))
	{
        MyRowNames_Acc = OutRowNames_Acc->GetRowNames();
		if (MyRowNames_Acc) //This fails, and why?
		{
			for (auto& ArrayElements_Acc : MyRowNames_Acc)
			{
				ItemTypeAndID_Acc.Type = EItemType::E_Accessories;
				ItemTypeAndID_Acc.ID = FName(ArrayElements_Acc);
				Arr.Add(ItemTypeAndID_Acc);//Adding elements
			}
		}
		else {print100s("Cast of Weapon Item Datas Failed: Line 339 :: Class MyGameMode"); return; }
	}
}break;
```

---

<div class="post-metadata">

**Author:** ![herb64](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@herb64](https://forums.unrealengine.com/u/herb64)\
**Post date:** [August 13, 2022, 3:56pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/2 "2022-08-13T15:56:36Z")

</div>

Your MyRowNames\_Acc should be of type TArray\<FName\>, so did you set this one correctly?

If so, this is already an array, you do not really need to check for ‘if (rownames)’. A check for the array size could be done, I added this below: ‘rownames.Num()’. But it is not needed, as the iteration in the for loop will handle this.

Here’s some working example, just printing the row names…

```auto
LoadingScreenDatatable = LoadObject<UDataTable>(NULL, TEXT("DataTable'/Game/Henry/DataTables/DT_Test2.DT_Test2'"));
if (LoadingScreenDatatable)
{
	TArray<FName> rownames = LoadingScreenDatatable->GetRowNames();
	if (rownames.Num() > 0) // not really needed to check!
	{
		for (auto& ArrayElement : rownames)
		{
			UE_LOG(LogHerb64, Display, TEXT("Rowname: %s"), *ArrayElement.ToString());
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 13, 2022, 4:05pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/3 "2022-08-13T16:05:18Z")

</div>

yes I have it as `TArray<FName> rownames`

> [@herb64](#):
>
> If so, this is already an array, you do not really need to check for ‘if (rownames)’. A check for the array size could be done, I added this below: ‘rownames.Num()’. But it is not needed, as the iteration in the for loop will handle this.

if i don’t check it for nullptr, the editor just crashed with error [Array has changed during ranged-for iteration!](https://forums.unrealengine.com/t/array-has-changed-during-ranged-for-iteration/627369) …

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 13, 2022, 4:12pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/4 "2022-08-13T16:12:45Z")

</div>

got idea from line in your post

> [@herb64](#):
>
> `LoadingScreenDatatable = LoadObject<UDataTable>(NULL, TEXT("DataTable'/Game/Henry/DataTables/DT_Test2.DT_Test2'"));`

and i changed mine too  
`("/Game/DataTables/DT_WeaponAcc")))`

should be

`("DataTable'/Game/DataTables/DT_WeaponAcc'")))`

Thank you very much for solving the issue 🙂

---

<div class="post-metadata">

**Author:** ![herb64](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@herb64](https://forums.unrealengine.com/u/herb64)\
**Post date:** [August 13, 2022, 4:31pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/5 "2022-08-13T16:31:16Z")

</div>

Yeah, it is a good idea to get the reference string using the Right Mouse Button menu from content browser and paste this into the code:

 ![grafik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/c/73c771aaccecba849d9c110043a0fb58ba04db89.png)

this resolves to

DataTable’/Game/Henry/DataTables/DT\_Test2.DT\_Test2’

---

<div class="post-metadata">

**Author:** ![herb64](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@herb64](https://forums.unrealengine.com/u/herb64)\
**Post date:** [August 13, 2022, 4:37pm UTC](https://forums.unrealengine.com/t/why-my-gettablerownames-failed/627748/6 "2022-08-13T16:37:30Z")

</div>

This “Array has changed…” error happens, if you change the array content while iterating over it. I looked at your code - indeed, you add items within the for loop.  
You could try to iterate with a for (i =…) loop to avoid these issues.  
See [this forum thread](https://forums.unrealengine.com/t/array-has-changed-during-ranged-for-iteration/354123).
