In my MySQL table I allow NULL values in some fields.
When I itterate through the result set I get an error whenever the reader hits such a NULL value.
Here is the code:
IDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
string[] catalog_info = {
(string)reader["tab_name"]
, (string)reader["document_n
ame"], (string)reader["comment_te
xt"]};
dataGridViewCurrentSession
PatientDoc
uments.Row
s.Add(cata
log_info);
}
Here is the error: "Unable to cast object of type 'System.DBNull' to type 'System.String'."
What I need is to instruct the reader to substitute an emplty string ("") for a NULL value
Start Free Trial