error when dataset returns a null value.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I got an error when the dataset returns a null value.
eg.
string a;
a = (string)ds.Tables[0].Rows[0][2];

How do I handle this error ? Thanks.

regards,
andrew
 
it works thanks

J055 said:
Check out the 'as' keyword.

e.g.

a = ds.Tables[0].Rows[0][2] as string;

Andrew


Andrew said:
hi,

I got an error when the dataset returns a null value.
eg.
string a;
a = (string)ds.Tables[0].Rows[0][2];

How do I handle this error ? Thanks.

regards,
andrew
 
Back
Top