It turns out that data charges to DataTable
in the following way:
private void cargarempresas()
{
dt_hogar = new DataTable();
String sql = "SELECT CAST(CONCAT(nombre,'-',apellido)AS CHAR) AS nombre,fechacreacion FROM hogar";
conexion.conectar();
datos = new MySqlDataAdapter(sql, conexion.con);
conexion.cerrar();
datos.Fill(dt_hogar);
var source = new BindingSource();
source.DataSource = dt_hogar ;
Dtgempresas.DataSource = source;
}
And I update the DataTable
in the following way:
private void btnActualizar_Click(object sender, EventArgs e)
{
cmdbder = new MySqlCommandBuilder(datos);
datos.Update(dt_hogar);
}
But the following error occurs:
The input string does not have the correct format.
To show the name and surname in a single column, I use the CONCAT
, but it turns out, that when I use it, I get the error when updating, any idea show the first and last name together, without using the CONCAT
so that I do not get an error when updating.