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);}