Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Iservice1.cs :



C#
namespace Employeer
{
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
          Employee GetEmployee();

    }
    [DataContract]
    public class Employee
    {
        [DataMember]
        public int Empid { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string Employeerid { get; set; }
    }

}


Service1.svc.cs:


C#
namespace Employeer
{
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
    public class Service1: IService1
    {
        String strConnection = ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString;
        SqlConnection conn = new SqlConnection(strConnection);
        public List<Employee> GetEmployee(int Employeerid)
        {
            List<Employee> objEmployees = new List<Employee>();
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select * from Employeetable where Employeerid Like '%'+@Employeerid+'%'", conn);
                cmd.Parameters.AddWithValue("@Employeerid", Employeerid);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);


            }
        }
Posted
Updated 28-Dec-12 22:48pm
v2

1 solution

The error is pretty clear:
'Employeer.Service1' does not implement interface member 'Employeer.IService1.GetEmployee()'

Your Interface definition includes:
C#
Employee GetEmployee();
but your class declares:
C#
List<Employee> GetEmployee(int Employeerid) {...}
These are not the same overload: the Interface expects a method with no parameters that returns an Employee, you have only declared a method that takes an integer and returns a List of Employees.
Either change your interface definition, or your class, (or both) as is appropriate.
 
Share this answer
 
Comments
Dhritirao's 29-Dec-12 4:55am    
'Employeer.Service1.GetEmployee(int)': not all code paths return a value
now im getting this error
OriginalGriff 29-Dec-12 5:05am    
Without seeing the code you have written for it, I can't help...
Dhritirao's 29-Dec-12 5:13am    
thanks for ur help
OriginalGriff 29-Dec-12 5:29am    
You're welcome!

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