[Help] Impulse Source Nobility Error.

09/12/2012 04:55 killersub#1
Hey guys I'm finally back and staying.

I've decided to learn the ropes of coding step by step so I took out a fresh copy of the impulse source and began coding on it(just recently). I coded nobility(parts from another reference), but the MySqlReader is giving me problems while I load up the console.

These are my variables at the top:
Code:
private DataSet _dataset;
        private DataRow _datarow;
        private int _row;
        const string Table = "table";
I fixed the NullException error for the Void Read() by replacing it with this:
Code:
public bool Read()
        {
            if (_dataset != null && _dataset.Tables[Table].Rows.Count > _row)
            {
                _datarow = _dataset.Tables[Table].Rows[_row];
                _row++;
                return true;
            }
            _row++;
            return false;
        }
don't know if it was a useful change but it worked(I guess).

I get an error now saying:
Quote:
Object Reference not set to an instance of an Object.
Line 24 NobilityTable.cs is this:
Code:
reader.Close();
which is part of this:
Code:
public static void Load()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("nobility");
            MySqlReader reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Game.ConquerStructures.NobilityInformation nobilityinfo = new Conquer_Online_Server.Game.ConquerStructures.NobilityInformation();
                nobilityinfo.EntityUID = reader.ReadUInt32("EntityUID");
                nobilityinfo.Name = reader.ReadString("EntityName");
                nobilityinfo.Donation = reader.ReadUInt64("Donation");
                nobilityinfo.Gender = reader.ReadByte("Gender");
                nobilityinfo.Mesh = reader.ReadUInt32("Mesh");
                Game.ConquerStructures.Nobility.Board.Add(nobilityinfo.EntityUID, nobilityinfo);
            }
            reader.Close();
            Game.ConquerStructures.Nobility.Sort(0);
            Console.WriteLine("Nobility information loaded.");
        }
And this is the Void Close():
Code:
public void Close()
        {
            _dataset.Clear();
        }
From there on I'm a little stuck.

I would appreciate a little help pointing me in the right direction, sorry for my "newb-ness" but I wanted to know what is causing this and why.

Regards, killersub.
09/12/2012 11:36 checker345#2
Free Bump!
09/13/2012 00:01 .Kinshi#3
Looks like _dataset in your Close void is null.
09/13/2012 01:09 killersub#4
Quote:
Originally Posted by .Kinshi View Post
Looks like _dataset in your Close void is null.
I did breakpoint it and it told me _dataset was in fact null.

the problem is that when I assign it as a new variable it still tells me it's null.

Example:
Code:
private DataSet _dataset = new DataSet();
it still tells me it's null.

Sorry for my low level of understanding but I need a little help as to what the problem is.
09/13/2012 02:41 Purple<3#5
Welcome back,
Maybe this might help?
[Only registered and activated users can see links. Click Here To Register...]
Read the comments :)

Also press this link(everyone):
[Only registered and activated users can see links. Click Here To Register...]
09/13/2012 10:11 Korvacs#6
If your learning to code step by step, why are you starting working on someone else's source?

Start fresh and actually learn step by step how to put together a project and over come the challenges you face as you go.
09/13/2012 12:20 _DreadNought_#7
Quote:
Originally Posted by Purple<3 View Post
Welcome back,
Maybe this might help?
[Only registered and activated users can see links. Click Here To Register...]
Read the comments :)

Also press this link(everyone):
[Only registered and activated users can see links. Click Here To Register...]
You know each thanks you give has a unique securityToken? That link will only work for you.
09/13/2012 18:34 killersub#8
Quote:
Originally Posted by Korvacs View Post
If your learning to code step by step, why are you starting working on someone else's source?

Start fresh and actually learn step by step how to put together a project and over come the challenges you face as you go.
Because I simply can not put myself to that test at the moment.

My IRL problems and duties are too much of a hassle for me to actually concentrate on C# "step by step"(what I meant by that was to start off with a fresh source that is feature-less(or so to speak) and work my way up slowly).
09/14/2012 03:45 Purple<3#9
Quote:
Originally Posted by _DreadNought_ View Post
You know each thanks you give has a unique securityToken? That link will only work for you.
ik