S
Simon Harvey
Hi everyone,
I'm wondering if there is some easy way to deal with null values being
returned in a DataRow.
When I get data from a database (Access) most of it is string based.
However, I don't always know if a particular row will contain any
information in any given column.
Sometimes there will be no information there, in which case I get a null
back.
The way I am getting values out of the DataTable is as follows:
foreach(DataRow row in config.Tables["usenet_accounts"].Rows){
try{
usenetAccount = new UsenetAccount((int)row["account_id"],
(string)row["username"],(string)row["password"],
(string)row["account_name"],
(string)row["email_address"], (string)row["contact_name"],
(string)row["nntp_server"],
(string)row["signature"],
(bool)row["default_account"], (bool)row["auto_monitor"],
(int)row["monitor_interval"]);
usenetAccounts.Add(usenetAccount);
}
}
As you can see there are quite a few columns of data there. Several of them
could return no information.
Is the only way round this to create if statements for each data column and
test to see if the value is null? Or is there an easier way that I'm just
not seeing?!
Thanks everyone
Take care
Simon
I'm wondering if there is some easy way to deal with null values being
returned in a DataRow.
When I get data from a database (Access) most of it is string based.
However, I don't always know if a particular row will contain any
information in any given column.
Sometimes there will be no information there, in which case I get a null
back.
The way I am getting values out of the DataTable is as follows:
foreach(DataRow row in config.Tables["usenet_accounts"].Rows){
try{
usenetAccount = new UsenetAccount((int)row["account_id"],
(string)row["username"],(string)row["password"],
(string)row["account_name"],
(string)row["email_address"], (string)row["contact_name"],
(string)row["nntp_server"],
(string)row["signature"],
(bool)row["default_account"], (bool)row["auto_monitor"],
(int)row["monitor_interval"]);
usenetAccounts.Add(usenetAccount);
}
}
As you can see there are quite a few columns of data there. Several of them
could return no information.
Is the only way round this to create if statements for each data column and
test to see if the value is null? Or is there an easier way that I'm just
not seeing?!
Thanks everyone
Take care
Simon