Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Aim-Want to display in chart form


My CS page

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MySql.Data.MySqlClient;
using System.Web.Script.Serialization;

public partial class charttype : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string a1 = Session["username"].ToString();
            string a2 = Session["pass"].ToString();
        }
        catch (Exception err)
        {
            //Server.Transfer("AdminLogin1.aspx");
        }


        string firstname = "", lastname = "";
        try
        {
            firstname = Session["firstname"].ToString();
        }
        catch (Exception err)
        {

        }

        try
        {
            lastname = Session["lastname"].ToString();
        }
        catch (Exception err)
        {

        }
        try
        {
            Label11.Text = "Hi,    " + firstname + "  " + lastname;
        }
        catch (Exception err)
        {

        }
    }

  [WebMethod]
  public static string MyMethod()  //This line is showing error
  {
Posted
Updated 8-Jul-13 1:32am
v4
Comments
Mukesh Ghosh 8-Jul-13 3:28am    
See no one is here to check each & every line that you have paste, tell us your problem or line no. that might help to trace the issue.
OriginalGriff 8-Jul-13 3:53am    
That is a code dump.
Edit your question, and cut it down to just the relevant parts - because nobody wants to wade through that to try and work out what you are talking about.
Help us to help you!
Use the "Improve question" widget to edit your question and provide better information.
[no name] 8-Jul-13 6:43am    
Your error message is perfectly clear. You are not returning a value from all paths in your MyMethod method. But since you did not show us any code relevant to that, we can't tell.

When you show us a code fragment, it is normally an idea to show us the section showing teh problem, rather than the bit above that...

But, since your method returns a string, and the error message is pretty explicit, it is fairly obvious: the compiler has found that there is at least one path through your MyMethod method which does not result in a return statement. This can be because you forgot to put it as the end, or that you have an if condition that returns a string, and an else that doesn't.

But you didn't show us the code, so it will be up to you to look at it and work out which piece of code is wrong!
 
Share this answer
 
ASPX PAGE
]]>


<asp:content id="Content1" contentplaceholderid="HeadContent" runat="Server" xmlns:asp="#unknown">

<asp:content id="Content2" contentplaceholderid="MainContent" runat="Server" xmlns:asp="#unknown">







<%----%>


google.load('visualization', '1', { packages: ['corechart'] });

]]>


$(document).ready(function () {

$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default6.aspx/GetData',

data: {},
success:
function (response) {
drawVisualization(response.d);
}

});
})

function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Name');
data.addColumn('number', 'Column Value');

for (var i = 0; i &lt; dataValues.length; i++) {
data.addRow([dataValues[i].ColumnName, dataValues[i].Value]);
}

new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, { title: " JQuery Charts Example" });
}



#todate
{
z-index: 1;
left: 577px;
top: 115px;
position: absolute;
width: 104px;
height:16px;
}
#fromdate
{
z-index: 1;
left: 276px;
top: 115px;
position: absolute;
width: 104px;
height:16px;

}







style="color:#000066; z-index: 1; left: 795px; top: 112px; position: absolute; height: 26px; width: 66px;";
id="go" value="GO" onmouseover="true" title="Click here to get details."/>



<asp:label id="Label1" runat="server" text="to Date">


style="z-index: 1; top: 116px; position: absolute;font-family: 'Tahoma'; left:474px;" Font-Bold="True"
ForeColor="#006697" Font-Size="Small">

<asp:label id="Label2" runat="server" text="from Date">


style="z-index: 1; left: 168px; top: 116px; position: absolute; font-family: 'Tahoma'; width: 101px;" Font-Bold="True"
ForeColor="#006697" Font-Size="Small">




CS PAGE
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MySql.Data.MySqlClient;
using System.Web.Script.Serialization;

public partial class Default6 : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }

    [WebMethod]
    //public static string GetData(int userid)
    public static List<Data> GetData()
    {
       
        List<Data> dataList = new List<Data>();

        MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
        string s = string.Empty;
        s = "select name,marks from jqchart";
        //string s1= "select count(name) from jqchart"; 
        //int s2 = Convert.ToInt32(s1);
        {
            MySqlCommand cmd = new MySqlCommand(s, con);
            {
                con.Open();
                cmd.ExecuteNonQuery();
                //string name;
                //int marks;
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                //for (int i = 0; i < s2; i++)
                {
                    string a=dr[0].ToString();
                    string b = dr[1].ToString();
                    dataList.Add(new Data(a,int.Parse(b)));
                      
                }

                return dataList;
            
            }
           
        }        
       
    }
    public class Data
    {
        public string ColumnName = "";
        public int Value = 0;

        public Data(string columnName, int value)
        {
            ColumnName = columnName;
            Value = value;
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900