Can't get datatable row

Hi, I’m trying to get a value from a row in my datatable, but I keep getting the error:

LogDataTable: Error: UDataTable::FindRow : '(null)' specified incorrect type for DataTable '/Game/Skills/DT_Skills.DT_Skills'.

DataTable:

Structure:

Structure code:

USTRUCT(BlueprintType)
struct FMyMiningDataTableRow : public FTableRowBase {
    GENERATED_BODY()

    int32 CurrentLevel;
    int32 CurrentMaxLevel;
    int32 MaxLevel;
    UTexture2D* Icon;
    float CurrentExperience;
    float ExpRequirement;
	ESKILL_TYPE SkillNameEnum;
};

Get row code:

void UMiningCharacterComponent::BeginPlay()
{
	FStringAssetReference AssetRef("DataTable'/Game/Skills/DT_Skills.DT_Skills'");
	DataTable = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *AssetRef.ToString()));

	FMyMiningDataTableRow* MyDataRow = DataTable->FindRow<FMyMiningDataTableRow>(FName("Mining"), nullptr, true);
	if (MyDataRow != nullptr) {
		MiningLevel = MyDataRow->CurrentLevel;
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Error Getting mining level"));
	}
}

Thanks!

  1. Right-click on Datatable and select “Copy Reference”

image

  1. Declare the path name as type FString in the code and paste the copied reference path.

    FString DataTable =“↑Your DataTable Reference Copy Here”;

  2. Perform the reference by loading the UDataTable object.

    UDataTable Ptr_Table = Cast(StaticLoadObject(UDataTable::StaticClass(), nullptr, DataTable));

  3. Find table row.
    FMyMiningDataTableRow Ptr_DataRow = Ptr_Table ->FindRow<FUserConfig_ItemHubData>(FName(“Mining”, “”);

If you still can’t find this row, it may be due to the mismatch between your VS encoding and UE encoding. Instead of manually writing “Minning” in the code, use blueprint parameter passing or data table traversal to retrieve this data.