I have an editor that is build in VS 2017 with Framework 4.7.2 and with Devexpress 17. It is an editor for an old game. With the Editor I can put NPC/Mobs in to the game world. I can compile it in Debug and Relase mode.
The editor has a stat window for level, faction. You can search for items and put it into the mob and there is a little screen that show the picture from the mob or you can add a picture to the mob.
The problem I encounter is this. I start the GUI Editor and I can see all the mobs that are available I can search for all the items. But I can`t see the picture from the mob and the stats are all empty and when I click in the table and I want to pick another mob the editor crash.
I tried to debug it and this is the error:
System.IndexOUtOffRangeExceptions -- There is no row at position 0.
But I have 200 rows in the SQL Table. For some reason it won`t update the mob and show the picture. Like it has no connection. And the editor point to this location.
// Get Last Mob Item ID
private int GetNextItemID()
{
DataTable lastInsert = SQL.ExecuteQuery("SELECT max(id) from mob_items;");
return int.Parse(lastInsert.Rows[0][0].ToString());
}
private int GetNextMobID()
{
DataTable lastInsert = SQL.ExecuteQuery("SELECT max(mob_id) from mob_base;");
return int.Parse(lastInsert.Rows[0][0].ToString());
}
====================================
The Debugger point to this Location:
return int.Parse(lastInsert.Rows[0][0].ToString());
I tried everything but I don`t know how I can fix this error.