0

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.

enter image description here

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.

John
  • 1
  • 1
  • Doesn't `SELECT max(id)` return a scalar value, hence no rows? – René Vogt Mar 16 '19 at 15:12
  • I was thinking the same. In the sql table there is no max. Only id. But if I remove the max I can`t compile it. I don`t know what they creator mean with Max. Is that the latest iD in the row. – John Mar 16 '19 at 15:57
  • I removed the max from the code: – John Mar 16 '19 at 16:01
  • I removed max from the code and it compile but when I compile in debug and I want to add an item to the mob or I want to click on another mob. I get the same error. There is no row at position 0. – John Mar 16 '19 at 16:02

0 Answers0