0
I would like to ask a question, because the first date does not work?
Cmd.Parameters.Addwithvalue("@dtUltAccess", "2017-01-01 01:01:01+09");
Error that returns:
Error inserting user - Error: 42804: column "usu_dataaccess" is of type timestamp without time zone but Expression is of type text
And this one works right
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’d like to pass a string with a date, how could I do that?
Thank you
Tried to pass the information to the bank with simple quotes
''
?– R.Santos