TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tushar Goel
NA
26
0
//Gettign error while creating chart///how to create ms chart based on button request and sql query data in c#?
Feb 1 2011 2:26 AM
Hi,
What i required: I have 2 text boxes for the "From Date" to "To date" and a button, when i press the button it should display the chart based on the textbox ranges and sql query. I have some tables from which i taking an input. I need to draw map between (severity and Actual) and (severity and Target) the result of that query is :
Severity Target Actual
TS2-CDMA 81 14
TS2-iDEN 62 28
TS1-CDMA 80 61
TS1-iDEN 80 82
I am getting error at the below point and also not sure whether i ill get desired results if executed good. Please help me it's urgent.
error i am getting :
Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.
where :
for
(
int
pointIndex = 0; pointIndex < rowList.Count; pointIndex++)
{
plotY =
Convert
.ToDouble(rowList[pointIndex]);
}
I am using below code.
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
}
protected
void
Button1_Click1(
object
sender,
EventArgs
e)
{
Chart1.Series[
"Series1"
].ChartType =
SeriesChartType
.Column;
Chart1.Series[
"Series1"
][
"DrawingStyle"
] =
"Emboss"
;
Chart1.ChartAreas[
"ChartArea1"
].Area3DStyle.Enable3D =
false
;
Chart1.Series[
"Series1"
].IsValueShownAsLabel =
true
;
FillData();
}
private
void
FillData()
{
con.Open();
SqlDataReader
myReader =
null
;
string
sqlquery1 =
String
.Format(
@"select ID.Severity ,tv.Target, Actual=COUNT(No.TicketNumber)*100/(select COUNT(TicketNumber)from tbl_NewOrderInfo) from tbl_NewOrderInfo NO inner join tbl_IssueDetail ID on ID.TicketNumber=NO.TicketNumber inner join tbl_TargetValue tv on ID.Severity=tv.Severity where NO.SLA='Met' and ID.EventStartTime between '"
+TextBox1.Text+
"' and '"
+TextBox2.Text+
"' group by ID.Severity ,tv.Target "
,con) ;
SqlCommand
myCommand1 =
new
SqlCommand
(sqlquery1, con);
myReader = myCommand1.ExecuteReader();
myReader.Read();
ArrayList
rowList =
new
ArrayList
();
while
(myReader.Read())
{
object
[] values =
new
object
[myReader.FieldCount];
myReader.GetValues(values);
rowList.Add(values);
}
double
plotY = 0;
if
(Chart1.Series[
"Series1"
].Points.Count > 0)
{
plotY = Chart1.Series[
"Series1"
].Points[Chart1.Series[
"Series1"
].Points.Count - 1].YValues[0];
}
for
(
int
pointIndex = 0; pointIndex < rowList.Count; pointIndex++)
{
plotY =
Convert
.ToDouble(rowList[pointIndex]);
Chart1.Series[
"Series1"
].Points.AddY(plotY);
}
Chart1.Series[
"Series1"
].XValueMember =
"Severity"
;
Chart1.Series[
"Series1"
].YValueMembers =
"Actual"
;
Chart1.DataBind();
con.Close();
Reply
Answers (
3
)
Bing API and MySQL
c#