bhoffman17 Report post Posted May 11, 2010 I am trying to pull a simple database: tring connString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Inf_Cap.mdf;Integrated Security=True;User Instance=True"; // OLD LINK Data Source=HECND7261TRBSQLEXPRESS;database=TestDatabase; UID=dbtest;PWD=87JamesH string strSQL = "SELECT TOP 5 Date AS Date, Used_Cap AS Used_Cap, Available_Cap " + "FROM Inf_Cap_Monthly " + "ORDER BY Date Desc " + "FOR XML AUTO"; SqlConnection objConnect = new SqlConnection(connString); objConnect.Open(); SqlCommand objCommand = new SqlCommand(strSQL, objConnect); SqlDataReader myReader = objCommand.ExecuteReader(); StringBuilder xmlData = new StringBuilder(); xmlData.AppendFormat("<chart caption='Infrastructure Capacity Usage' subCaption='Monthly' xAxisName='Month' yAxisName='% Used' showValues='0' formatNumberScale='0' showBorder='1'>"); while (myReader.Read()) { xmlData.AppendFormat("<set label='{0}' value='{1}' />", myReader["Date"].ToString(), myReader["Used_Cap"].ToString()); } myReader.Close(); xmlData.Append("</chart>"); //Create the chart with data from xmlData Literal1.Text = FusionCharts.RenderChartHTML("../FusionCharts/Column3D.swf", xmlData.ToString(), "", "myFirst", "600", "300", false); objConnect.Close(); objConnect.Dispose(); } } } First is the code even all i need? Second i get a indexoutofrange exception in this area: while (myReader.Read()) { xmlData.AppendFormat("<set label='{0}' value='{1}' />", myReader["Date"].ToString(), myReader["Used_Cap"].ToString()); } Thanks Ben Share this post Link to post Share on other sites
bhoffman17 Report post Posted May 11, 2010 Nevermind i was pushing XML, but i had the xmlData.ToString in the dataurl. lol THank you Jesus for answering my prayers! Share this post Link to post Share on other sites
Guest Basundhara Ghosal Report post Posted May 11, 2010 Hi, Thanks for your reply and sharing your idea. Glad that your issue is resolved. Keep smiling and keep FusionCharting. Share this post Link to post Share on other sites