0

I'm trying to add some data to the database using an sql query in c#, but I got this error code in my service class, it says: "An object reference is required for the non-static field, method, or property 'SupervisorDao.AddSupervisor(supervisor)'.

I don't know what to do.

public void AddSupervisor(Supervisor supervisor)
{
    SupervisorDao.AddSupervisor(supervisor)
}
Jan
  • 11
  • 3

1 Answers1

0

You need an instance of the SupervisorDao object before you can call the methods (unless you make it a static method).

SupervisorDao superDao = new SupervisorDao();
superDao.AddSupervisor(supervisor);

Edit: Is SupervisorDao an interface? You'll have to create an object that inherits this interface.

d_w_
  • 84
  • 5