Newbie: How to detect if an item in a DB record is null (mysql)...
-
Hi all... Just a quick one... I am trying to pull data from a mysql database and I am falling foul of a null data error... I am querying a mysql database and pulling a record containing 38 items... However it is throwing errors because some of the items are null... What is the best way to detect if the item is null? So I can do something about it... Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
Hi all... Just a quick one... I am trying to pull data from a mysql database and I am falling foul of a null data error... I am querying a mysql database and pulling a record containing 38 items... However it is throwing errors because some of the items are null... What is the best way to detect if the item is null? So I can do something about it... Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
Can you provide the code giving error? Mubashir
Every job is a self portrait of the person who did it.
Here is a bit of the code:
// build query string mysql_query = "SELECT * FROM rt_sip WHERE id = " + id + " ORDER BY id"; // submit query mysql_reader = mysql_send_query(mysql_query); while (mysql_reader.Read()) { // extract data from record temp_id = (int)mysql_reader[0]; temp_name = (string)mysql_reader[1]; temp_accountcode = (string)mysql_reader[2]; ... ... ... }
Phil"Rules are for the obedience of fools and the guidance of wise men"
-
Here is a bit of the code:
// build query string mysql_query = "SELECT * FROM rt_sip WHERE id = " + id + " ORDER BY id"; // submit query mysql_reader = mysql_send_query(mysql_query); while (mysql_reader.Read()) { // extract data from record temp_id = (int)mysql_reader[0]; temp_name = (string)mysql_reader[1]; temp_accountcode = (string)mysql_reader[2]; ... ... ... }
Phil"Rules are for the obedience of fools and the guidance of wise men"
-
Hi all... Just a quick one... I am trying to pull data from a mysql database and I am falling foul of a null data error... I am querying a mysql database and pulling a record containing 38 items... However it is throwing errors because some of the items are null... What is the best way to detect if the item is null? So I can do something about it... Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
Hi all... Just a quick one... I am trying to pull data from a mysql database and I am falling foul of a null data error... I am querying a mysql database and pulling a record containing 38 items... However it is throwing errors because some of the items are null... What is the best way to detect if the item is null? So I can do something about it... Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
Use the IsDBNull method. Example:
if (mysql_reader.IsDBNull(1) {
temp_name = null;
} else {
temp_name = mysql_reader.GetString(1);
}--- b { font-weight: normal; }
Yep I tried that but got the same error message... Will keep looking...
"Rules are for the obedience of fools and the guidance of wise men"
-
Yep I tried that but got the same error message... Will keep looking...
"Rules are for the obedience of fools and the guidance of wise men"