0
I can’t enter in the fields dateCreation and dataRefMovimento in the sql database
private Contexto contexto;
public void Inserir(RegCabecalho regCabecalho)
{
var strQuery = "";
strQuery += " INSERT INTO regCabecalho (tipoReg, dataCriacao,horaCriacao,dataRefMovimento,IDArq,codParceiro
,numeroSeq,versaoLayout) ";
strQuery += string.Format(" VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}') " ,
regCabecalho.tipoReg, regCabecalho.dataCriacao,
regCabecalho.horaCriacao, regCabecalho.dataRefMovimento, regCabecalho.IDArq,
regCabecalho.codParceiro,
regCabecalho.numeroSeq, regCabecalho.versaoLayout
);
using (contexto = new Contexto())
{
contexto.ExecutaComando(strQuery);
}
}
"I can’t" it’s too vague. What happens? Does it make a mistake? Without this information it’s hard for anyone to help you.
– André Ribeiro
What is the error message?
– Intruso
Which database? are you using Entity Framework? where are you passing your Datetime field? what is Regcabecalho for ?
– Marco Souza
suggestion, always enter the date in the format'yyyymmdd' example '20171201'
– Dorathoto