Janis Peksa

Janis Peksa

  • NA
  • 152
  • 50.7k

Check if Dataset is Null?

Jul 8 2011 4:33 AM
I have simple code, like this: http://paste.php.lv/9aad9c370b9104e5e42908c8db0f1356?lang=csharp

I have problem if I enter SELECT id2 FROM table and column id2 doesn't not exist it's shows me error:
http://uploadpic.org/storage/2011/KyrNTJB1zK8blk8WV17VwbLlt.png

So I tried many ways but nothing helps:
1) if (ds != null)
2) if ((ds != null) && (ds.Tables[0].Rows.Count != 0))

I searched it all around google so no help there.
Help me please.



Answers (2)