A
AAJ
Hi all
A quick question on Datasets.....
I populate a dataset from a SQL SERVER 2000 database via a data adapter. I
then use the dataset to populate member variables of my class.
I know the datatype of a column in the database, so I use convert. to
convert the results in to the same datatype within my class i.e.
m_TimeToAction = Convert.ToDecimal(currentRow["TimeToAction"]);
where m_TimeToAction is a Decimal.
The problem is when the dataset field is empty (not null) i.e. has a value
of {}.
Is there a safe way of testing for this condition for all the fields. For
instance, if an empty record definitely returned null I could use
if (currentRow["TimeToAction"] != null) m_TimeToAction =
Convert.ToDecimal(currentRow["TimeToAction"]);
but obviously, as the result isn't guaranteed to be null, the above won't
always work!
I know I could test the length, and also compare to '', but I am looking for
the best all encompassing way to ensure the returned data is valid
any thoughts most welcome
Andy
A quick question on Datasets.....
I populate a dataset from a SQL SERVER 2000 database via a data adapter. I
then use the dataset to populate member variables of my class.
I know the datatype of a column in the database, so I use convert. to
convert the results in to the same datatype within my class i.e.
m_TimeToAction = Convert.ToDecimal(currentRow["TimeToAction"]);
where m_TimeToAction is a Decimal.
The problem is when the dataset field is empty (not null) i.e. has a value
of {}.
Is there a safe way of testing for this condition for all the fields. For
instance, if an empty record definitely returned null I could use
if (currentRow["TimeToAction"] != null) m_TimeToAction =
Convert.ToDecimal(currentRow["TimeToAction"]);
but obviously, as the result isn't guaranteed to be null, the above won't
always work!
I know I could test the length, and also compare to '', but I am looking for
the best all encompassing way to ensure the returned data is valid
any thoughts most welcome
Andy