I am a pretty new developer and I am trying to setup a ODS database connection. I am referencing an example from another programmers work that use to work here. Here is the code. It throws an error on after this. statement. I have my work exactly like his if you want to see his just leave comment it's several lines long.
public ODSData_Codename.TrayLabelReferenceRow toDataRow()
{
ODSData_Codename.TrayLabelReferenceRow row= null;
row.LabelName = this.LabelName;
row.LabelCode = this.LabelCode;
row.LabelStock = this.LabelStock;
return row;
}
Are you getting a NullReferenceException
, Object reference not set to an instance of an object?
you're first line makes row point to null. null doesn't have a property of LabelName. You need to instantiate row to an object of class ODSData_Codename.TrayLabelReferenceRow
You should look at this What is a NullReferenceException and how do I fix it?