0
I have this mistake in my code:
try
{
localhost.Agendamento a = new localhost.Agendamento();
a.Cliente.Cpf = "1909009921";
a.Servico.Cod_serv = 1;
a.Data = Convert.ToDateTime("11/02/2017");
a.Hora = Convert.ToDateTime("11:50");
Service1 sv = new Service1();
sv.CadastrarAgendamento(a);
MessageBox.Show("Cadastrou!");
}catch(Exception ex)
{
MessageBox.Show("Error" + ex.Message);
}
The Exception activates when it reaches the line
a.Cliente.Cpf = "1909009921";
The exception is "Object reference not defined for an instance of an object"
Its object
Cliente
was instated ? could be the problem he is trying to accessCliente.cpf
whileCliente
isnull
. try debugging and check this.– William Cézar