//declare nullable integer value int? myValue = ds.Tables[0].Rows[0]["COMPANYID"]; if (myValue!=null) { //proceed }
int result = ds.Tables[0].Rows[0]["COMPANYID"] == DbNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["COMPANYID"]);
int result = 0; if(Int32.TryParse(ds.Tables[0].Rows[0]["COMPANYID"], result)) { //result has been succesfully converted into integer value }
com_id = Convert.IsDBNull(ds.Tables[0].Rows[0]["COMPANYID"]) ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["COMPANYID"]);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)