Good afternoon, I have a problem with this code since I am trying to load a datagrid by means of an object from which I obtain records from a table in sql, when executing it it shows me the error Object reference not established as instance of an object , already check my code and my way of seeing I am well created the instances, who knows what it can be?
public void CargarGrid()
{
try
{
MostrarNomina objMostrarNomina = new MostrarNomina();
DataTable dtNomina = new DataTable();
if (objMostrarNomina.dtMuestraDatosNomina()!=null)
{
dtNomina = objMostrarNomina.dtMuestraDatosNomina();
dgvMostrarNominas.DataSource = dtNomina;
}
}
catch (Exception ex)
{
ex.ToString();
}
}
private void btnMuestraNomina_Click(object sender, EventArgs e)
{
try
{
CargarGrid();
}
catch (Exception ex)
{
ex.ToString();
}
}
Thanks for your valuable help. Greetings