private DataSetNumber1.TBL_AppointmentRow _selectedAppointmentRow = null ; private DatasetNumber1.TBL_EngineerRow _selectedEngineerRow = null; public myEditSchedulerDialog () { initializeComponent (); _selectedAppointmentRow = new DataSetNumber1.TBL_AppointmentRow (null); }I keep getting a object reference not set to an instance of an object error.
Any help would be appreciated.
regards
Afzaal Ahmad ZeeshanPosted Mar 23, 2015, 4:14 PM
Because, using new keyword and creating the object would remove any chances for getting a null exception, until an underlying object is null. Please use breakpoints in your code and debug it, going through every statement in your code to see which statement, expression or variable throws exception, then try to instantiate it to fix this problem. It is hard to tell without having to look at the code of your project or how you use them in your application.
Pelumi EluyeraPosted Mar 23, 2015, 11:15 AM
I have tried using
_selecdted AppointmentRow = new DataSetNumber1.Tbl_AppointmentRow ();
Regards
Afzaal Ahmad ZeeshanPosted Mar 23, 2015, 11:00 AM
Please, initialize the variables which have been given a value of null; null means nothing, it doesn't exist. That is why you're getting this error. Once your object would have some value, it would not throw similar exception again. You can use new Constructor() to instantiate the object.