1
I would like to know how to recover a date as given from the recorded Milliseconds in a MS SQL Server 2019 database using VB.Net + ADO.Net.
Whenever I try to rescue the date, comes in the fomrmato "dd/MM/yyyy HH:mm:ss" I would also like to have the ". fff", but I can’t recover this information in the BD.
*** model code:
Private _DataAlteracao As DateTime
Public Property DataAlteracao() As DateTime
Get
Return _DataAlteracao
End Get
Set(ByVal value As DateTime)
_DataAlteracao = value
End Set
End Property
*** INSERT code:
Public Overloads Function InserirHistorico(entidade As ClsHistoricoDomain) As Object
Dim objConfirma As Object
MyBase.LimparStrComando()
MyBase.StrComando.AppendLine(" INSERT INTO tblHistorico (")
MyBase.StrComando.AppendLine(" CNPJ, ")
MyBase.StrComando.AppendLine(" RazaoSocial, ")
MyBase.StrComando.AppendLine(" NomeFantasia, ")
MyBase.StrComando.AppendLine(" CodigoSistema, ")
MyBase.StrComando.AppendLine(" DataAlteracao) ")
MyBase.StrComando.AppendLine(" VALUES (")
MyBase.StrComando.Append(IIf(Not String.IsNullOrEmpty(entidade.CNPJ), String.Format("'{0}',{1}", entidade.CNPJ, Environment.NewLine), "NULL,"))
MyBase.StrComando.Append(IIf(Not String.IsNullOrEmpty(entidade.RazaoSocial), String.Format("'{0}',{1}", entidade.RazaoSocial, Environment.NewLine), "NULL,"))
MyBase.StrComando.Append(IIf(Not String.IsNullOrEmpty(entidade.NomeFantasia), String.Format("'{0}',{1}", entidade.NomeFantasia, Environment.NewLine), "NULL,"))
MyBase.StrComando.Append(IIf(Not String.IsNullOrEmpty(entidade.CodigoSistema), String.Format("'{0}',{1}", entidade.CodigoSistema, Environment.NewLine), "NULL,"))
MyBase.StrComando.Append(IIf(Not String.IsNullOrEmpty(entidade.DataAlteracao), String.Format("'{0}',{1}", entidade.DataAlteracao, Environment.NewLine), "NULL,"))
MyBase.StrComando.AppendLine(")")
objConfirma = SQLHelper.ExecuteScalar(StrComando.Remove(StrComando.ToString.LastIndexOf(","), 1).ToString(), True)
Return objConfirma
End Function
*** SELECT ALL CODE:
Public Overrides Function SelecionarTodos() As List(Of ClsHistoricoDomain)
MyBase.LimparStrComando()
MyBase.StrComando.AppendLine(" SELECT CNPJ, ")
MyBase.StrComando.AppendLine(" RazaoSocial, ")
MyBase.StrComando.AppendLine(" NomeFantasia, ")
MyBase.StrComando.AppendLine(" CodigoSistema, ")
MyBase.StrComando.AppendLine(" DataAlteracao ")
MyBase.StrComando.AppendLine(" FROM tblHistorico ")
Return MyBase.RetornaLista(StrComando.ToString())
End Function