2
I am trying to enter in the Mysql database the date of birth of the user, in C# the attribute data_birth is of type DateTime and in Mysql the attribute data_nascimento is of type Date, to insert C# I’m doing so:
DateTime nascimento = Convert.ToDateTime(txNascimento.Text);
bDep.Data_nascimento = nascimento;
Obs:. bDep is the basic class of the dependent
And in the dependent’s data class I’m inserting thus:
public void insertDependente (BDependente bDep) {
      string sql = "INSERT INTO dependente(id_funcionario, nome, grau_parentesco, data_nascimento) ";
             sql += "VALUES ("+bDep.Funcionario.Id_funcionario+", '"+bDep.Nome+"', '"+bDep.Grau_parentesco+"', '"+bDep.Data_nascimento+"')";
            conn.update(sql);
        }
am selecting thus:
string sql = "SELECT id_dependente, id_funcionario, nome, grau_parentesco, data_nascimento ";
       sql += "FROM dependente";
                while (mdr.Read()) {
                    BDependente bDepe = new BDependente();
                    bDepe.Id_dependente      = mdr.GetInt16("id_dependente");
                    bDepe.Funcionario.Id_funcionario = mdr.GetInt16("id_funcionario");
                    bDepe.Nome               = mdr.GetString("nome");
                    bDepe.Grau_parentesco    = mdr.GetString("grau_parentesco");
                    bDepe.Data_nascimento    = mdr.GetDateTime("data_nascimento");
                    lDep.Add(bDepe);
                }
Every time I register a new addict at the bank it appears like this:
The first record was made in Mysql itself, and even so when I search in C# it brings the time and when I search in C# the other dependent, appears this other error:



The error only occurs when the date is written wrong or happens on any date line?
– Maniero
Error happens when recording ! And when I make one
SELECTat the bank– Ikaro Sales
That’s not what I asked.
– Maniero