I would like to ask a question, why does not the first date work?
Cmd.Parameters.AddWithValue ("@ dtUltAccess", "2017-01-01 01: 01: 01 + 09");
Error returning:
Error inserting user - Error: 42804: column "usu_dataacesso" is of type timestamp without time zone but expression is of type
And that works fine
Cmd.Parameters.AddWithValue ("@ dtCadastro", NpgsqlTypes.NpgsqlDateTime.Now);
public void insere()
{
try
{
//Abre a conexao para insercao
abrirConexao();
Cmd = new NpgsqlCommand("insert into \"Cadastro\".\"usuario\" (usu_nome,usu_cargo,usu_cpf,usu_dataAcesso,usu_dataCadastro,usu_status,usu_login,usu_senha) values (@nome,@cargo,@cpf,@dtUltAcesso,@dtCadastro,@status,@login,@senha)", Con);
Cmd.Parameters.AddWithValue("@nome", "Flavio");
Cmd.Parameters.AddWithValue("@cargo","TI");
Cmd.Parameters.AddWithValue("@cpf", "0101010101");
Cmd.Parameters.AddWithValue("@dtUltAcesso", "2017-01-01 01:01:01+09");
Cmd.Parameters.AddWithValue("@dtCadastro", NpgsqlTypes.NpgsqlDateTime.Now);
Cmd.Parameters.AddWithValue("@status", "A");
Cmd.Parameters.AddWithValue("@login", "fla");
Cmd.Parameters.AddWithValue("@senha", "123");
Cmd.ExecuteNonQuery();
MessageBox.Show("Usuario Inserido com Sucesso");
}
catch (Exception ex)
{
Console.WriteLine("Erro ao inserer usuario - Erro: " + ex.Message);
}
But I would like to pass a string with the date, how could I do that?
Thank you