C# oledb database connection error sometimes

I have 3 classes in a program im working on and a dataBase, the classes are lgdWeapon, lgdWeaponResult, and searchForLgdWeapon. lgdWeaponResult and searchForLgdWeapon are both inside of a bigger class called dataBase. searchForLgdWeapon gets data out of the database, and return a lgdweaponResult class with the data in it, then Lgdweapon gets that information from a result class it makes.

Code DataBase dataBase = new DataBase(); DataBase.lgdWeaponResults results = dataBase.SearchForLgdWeapon(r.Next(0,22));

The problem I'm having is that the first time I try to set a variable in lgdWeapon to a variable from lgd weapon result EX : _StrBuff = results.strBonus;

I get this error System.NullReferenceException was unhandled View Details : {"Object reference not set to an instance of an object."}

Sometimes I get this error Sometimes I don't I'd like to know what might be causing it or how I can find out what is causing it So I can find out how to fix it, can anyone help me?

by imgonnagetshocked via /r/csharp

Leave a Reply