OZ Report post Posted March 15, 2010 I have Nulls in my database. How do convert Null to say 0 Share this post Link to post Share on other sites
srividya_sharma Report post Posted March 15, 2010 Hi Can you tell us the technology you are using? Thanks Srividya Share this post Link to post Share on other sites
OZ Report post Posted March 16, 2010 Code is below.It works fine except when there are nulls, we then get the dreaded Object reference not set to an instance of an object. ///THIS IS THE CODE public string GetManagementControls() { StringBuilder xmlData = new StringBuilder(); //Generate the chart element xmlData.Append( "<chart caption='' subCaption='RISK SCORES ' pieSliceDepth='30' showBorder='0'useRoundEdges = '1' formatNumberScale='0' connectNullData='0' numberSuffix=''>"); string factoryQuery = "SELECT AVG(CAST(SQone.SQoneScore2 AS INT)) as TotQ FROM SQone "; DbConn oRs = new DbConn(factoryQuery); //Iterate through each record while (oRs.ReadData.Read()){ String LableActivity = " ";LableActivity = " Documentation";xmlData.AppendFormat( "<set label='{0}' value='{1}' />", LableActivity, oRs.ReadData["TotQ"].ToString()); //xmlData.AppendFormat("<set label='{0}' value='{1}' />", (oRs.ReadData["LocationName"].ToString()), oRs.ReadData["ImpairScore"].ToString()); //xmlData.AppendFormat("<set label='{0}' value='{1}' />", oRs.ReadData["Complete"].ToString(), oRs.ReadData["TotQ"].ToString());} oRs.ReadData.Close(); //Close chart elementxmlData.Append( "</chart>"); //Create the chart - Pie 3D Chart with data from xmlData return FusionCharts.RenderChart("../FusionCharts/Bar2D.swf?noCache=2", "", xmlData.ToString(), "FactorySum2", "600", "300", false, false);} Share this post Link to post Share on other sites
Rahul Kumar Report post Posted March 17, 2010 Hi, Could you please use the following code and try again? if (!oRs.ReadData["TotQ"].Equals(System.DBNull.Value)) { xmlData.AppendFormat("<set label='{0}' value='{1}' />", LableActivity, oRs.ReadData["TotQ"].ToString()); } else { xmlData.AppendFormat("<set label='{0}' value='0' />", LableActivity); } Share this post Link to post Share on other sites
OZ Report post Posted April 25, 2010 Thanks for that it worked fine. Really appreciate you assistance Share this post Link to post Share on other sites
Guest Basundhara Ghosal Report post Posted April 25, 2010 Hi, You are most welcome. Thanks for your kind words. We are glad that your issue is resolved. Keep smiling and keep FusionCharting. Share this post Link to post Share on other sites