The recent operation of the database, you need to determine whether the returned field value is empty, collected on the Internet 3 ways for everyone to refer
1 through System.DBNull, most of the online use of this method.
Copy CodeThe code is as follows:
DataTable DT; Assuming the field is name, DT has saved the data
dt.rows[0]["name"] = = System.DBNull.Value; Determines whether the name field of the first row of data is empty
2 Judging by IsNull
Copy CodeThe code is as follows:
DataTable DT; Assuming the field is name, DT has saved the data
Dt.rows[0]. IsNull ("name"); Determines whether the name field of the first row of data is empty
3 Judging by ToString ()
Copy CodeThe code is as follows:
DataTable DT; Assuming the field is name, DT has saved the data
dt.rows[0]["Name"]. ToString () = = ""; Determine if the name field of the first row of data is empty address: http://www.jb51.net/article/35234.htm
C # Three methods to determine whether the field values taken out of the database are empty (NULL)