0

I have this error in my program on the next line of code...

private void btnGrabar_Click(object sender, EventArgs e) {
    if (tbNombres.Text.Trim().Length > 0) {
        contacto Persona = new contacto();
        if (temp == 0) {
            Persona.AgregarContacto(tbNombres.Text,
                                    tbDireccion.Text, tbTelefono.Text, tbCelular.Text, tbEmail.Text,
                                    fechaActual, Convert.ToInt32(cboProfesion.SelectedValue.ToString()),
                                    Convert.ToInt32(cboPais.SelectedValue.ToString()));
        }
    }
}

the program is an organizer and you put info like name, cellphone, etc. i think the problem can be on my combobox but I don't really now, please help, if you need me to put the whole code just let me know.

Matthew Runo
  • 1,357
  • 3
  • 19
  • 43
  • 1
    Welcome to Stackoverflow, please read [How To Ask](https://stackoverflow.com/help/how-to-ask). Pay special attention to [How To Create MCVE](https://stackoverflow.com/help/mcve). The more effort you'll put into posting a good question: one which is easy to read, understand and which is [on topic](https://stackoverflow.com/help/on-topic) - the chances are higher that it will attract the relevant people and you'll get help even faster. Good luck! – Nir Alfasi Nov 02 '17 at 23:30
  • What on earth does this have to do with SQL? That looks *a lot* more like C# code than SQL code. – David Nov 02 '17 at 23:33
  • all the information that is going to be add on the organizer will be added to a database on sql – ALBERTO HAZAEL MEZA GUERRERO Nov 02 '17 at 23:34

1 Answers1

0

A NullReferenceException means that somewhere in your code you try to access something that is undefined. The . operator causes this, when the word on the left of the operator is null.

Add breakpoints in your method, hover over the object and properties and try to find out, why which object or property is null.

These are basic debugging skills. Please have a look for how to debug an application; this will help you, here.

Chris Tophski
  • 860
  • 1
  • 6
  • 21