I'm working with C # and the PostGreSQL Database, I have a field of type Date where it can be filled in dd / mm / yyyy or empty null. the same problem is related to any field of the table, if it is empty, even if it may be, the error occurs.
When I do a select to retrieve all data and assign to a DataTable the following error occurs
An exception of type 'System.Data.ConstraintException' occurred in System.Data.dll but was not handled in user code
Additional information: Falha ao ativar restrições. Uma ou mais linhas contêm valores que violam as restrições non-null, unique ou foreign-key.
Method Used
public DataTable RetornaDT(string sSQL)
{
DataTable dtDados = new DataTable();
if (ConectaBanco())
{
_comando.CommandText = sSQL;
dtDados.Load(_comando.ExecuteReader());
DesconectaBanco();
}
return dtDados;
}
Where do I have the following table in the database
CREATE TABLE conta
(
con_codigo serial NOT NULL,
con_descricao character varying(60),
con_valordaconta real,
con_valoraserpago real,
con_valorjapago real,
con_formapagamento character varying(2),
con_dinheiroouporc character varying(2),
con_desconto real,
con_juros real,
con_jurosam real,
con_multaporatraso real,
con_datalancamento date,
con_datavencimento date,
con_datapagamento date,
CONSTRAINT contas_pkey PRIMARY KEY (con_codigo)
)
WITH (
OIDS=FALSE
);
ALTER TABLE conta
OWNER TO postgres;