Hi,
I am using below query to fetch single integer value. Query is 100% right. but getting "Object reference not set to an instance of an object."
DataSet Panes = new DataQuery("custom.challenge.AccordionPanes") .Columns("Panes") .Where("challenge.NodeID", QueryOperator.Equals, 45894) .Execute();
I am trying to get value from syntax
string panesValue = (string)Panes.Tables[0].Rows[0][0];
But getting "NullReferenceException: Object reference not set to an instance of an object."
Please help ?
Are you doing this in a foreach statement?
foreach(DataRow r in Panes.Tables[0].Rows) { string panesValue = ValidationHelper.GetString(r["ColumnName"], "" ); //perform action with value }
On top of what Josh mentions you might also do a check to see if the dataset is empty
if(!DataHelper.IsEmptyDataSet(Panes)) { // do your work }
Please, sign in to be able to submit a new answer.