Hojoformo
asked on
Datatable null - not set to an instance of an object - best approach for handling
What is the best way to program for a null table. I have a C# program that calls a class to fill a DataTable named DS based on a condition. It is possible the datatable will return null from the call and the program crashes with "Object Not Set to an Instance of An Object". What is the best way to handle this conidtion? Should I add a dummy row to the table if the condition is not before returning? or is there a command that will set this object object a null instance?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it was defined with a a new dataset, why?
ASKER
it was defined like DataSet ds = new DataSet();
because if ther is not data and dataset is defined witout keyword New, you will get an error.
can you post some code?
can you post some code?
Like
dim ds as new dataset
or
dim ds as new datatable?