Click here to Skip to main content
16,004,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace RohitWebService
{
    /// <summary>
    /// Summary description for RohitService
    /// </summary>
    [WebService(Namespace = "http://Rohitshukla.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class RohitService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloRohit()
        {
            return "code is done by Rohit Shukla";
        }

        [WebMethod]
        public List<String>[] Marks(string sem)
        {

            List<String>[] data =  semester.marks(sem);
            return data;
        }
    }
}


XML
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using MySql.Data.MySqlClient;

namespace RohitWebService
{
    public class semester
    {



        public static List<String>[] marks(String mark1)
        {
            int i = 0;
            //Create a list to store the result
            List<string>[] list = new List<string>[4];
            list[0] = new List<string>();
            list[1] = new List<string>();
            list[2] = new List<string>();
            list[3] = new List<string>();




            String mysqlconnection = "server=localhost;;database=rohit_marks;uid=root;password=root;";

            MySqlConnection connection = new MySqlConnection(mysqlconnection);

            MySqlCommand cmd;
            connection.Open();
            try
            {
                //Create Command

                cmd = connection.CreateCommand();
                cmd.CommandText = "select * from marks where sem = @sem ;";
                cmd.Parameters.AddWithValue("@sem", mark1);
                cmd.ExecuteNonQuery();

                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    list[0].Add(dataReader["subject"] + "");
                    list[1].Add(dataReader["sem"] + "");
                    list[2].Add(dataReader["mark_obtained"] + "");

                }

                //close Data Reader
                dataReader.Close();
            }
            catch (MySqlException)
            {
                throw;
            }

            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
            return list;

        }
    }
}
Posted
Updated 15-Oct-13 5:23am
v2
Comments
Sergey Alexandrovich Kryukov 15-Oct-13 11:28am    
In what line?
—SA
Member 10331915 15-Oct-13 11:42am    
i don't know
when i invoke the web services in new tab
this appears
System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS1026: ) expected
error CS1002: ; expected
error CS1525: Invalid expression term ')'
error CS1002: ; expected
error CS1525: Invalid expression term ')'
error CS1002: ; expected
error CS1026: ) expected
error CS1002: ; expected
error CS1525: Invalid expression term ')'
error CS1002: ; expected
error CS1525: Invalid expression term ')'
error CS1002: ; expected

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

Member 10331915 15-Oct-13 12:04pm    
sorry but i complied all the code and then i deployed it.
i am using visual studio 2010 express if there is any error in the code it will tell
plz tell if there is any other method to compile my code and know where the error is

1 solution

This is just the syntax error. You cannot say "I don't know". Always fully compile all your project before trying to deploy it, and the compiler will tell you where the error is.

—SA
 
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