Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Error de conversion (https://www.clubdelphi.com/foros/showthread.php?t=75352)

Paulao 16-08-2011 19:07:34

Error de conversion
 
<e lo da error de conversion pero no hay nada.

Código Delphi [-]
Conversion failed when converting datetime from character string
Código Delphi [-]
DM.qryAtualiza.Sql.Clear;
  if (rgBanco.ItemIndex = 1) and (edtQtde.Text <> '') then
    DM.qryAtualiza.Sql.Add('select top ' + edtQtde.Text + ' numero_conhecimento,data_emissao_conhecimento,filial_origem ' +
                           ' from conhecimento_carga where data_emissao_conhecimento = ''1899-12-30 00:00:00.000''');
  DM.qryAtualiza.Open;
  sql := Memo1.Lines.Text;
  Gauge1.Visible := True;
  gauge1.MinValue := 0;
  gauge1.MaxValue := DM.qryAtualiza.RecordCount;
  //pb.Max := DM.qryAtualiza.RecordCount;
  //pb.Position := 0;
  DM.qryAtualiza.First;
  while not DM.qryAtualiza.Eof do
  begin
    try
      //DM.Conn.BeginTrans;
      Application.ProcessMessages;
      qry.SQL.add(sql);
      qry.Parameters.ParamByName('Filial').Value  := DM.qryAtualiza.FieldByName('filial_origem').AsString;
      qry.Parameters.ParamByName('Numero').Value  := DM.qryAtualiza.FieldByName('numero_conhecimento').AsString;
      qry.Parameters.ParamByName('Emissao').Value := DM.qryAtualiza.FieldByName('data_emissao_conhecimento').AsDateTime;
      qry.ExecSQL;

esta es mi query de actualizacion

Código Delphi [-]
UPDATE

CONHECIMENTO_CARGA

SET

DATA_EMISSAO_CONHECIMENTO = COALESCE(

(SELECT DISTINCT

OPERACOES_DATA.DATA FROM OPERACOES_DATA

WHERE

OPERACOES_DATA.CONTRATO = 

CONHECIMENTO_CARGA.NUMERO_CONHECIMENTO AND

OPERACOES_DATA.COD_CREDENCIADA = 

CONHECIMENTO_CARGA.FILIAL_ORIGEM AND

OPERACOES_DATA.DATA = 

CONHECIMENTO_CARGA.DATA_EMISSAO_REAL), 

DATA_EMISSAO_CONHECIMENTO )

WHERE

DATA_EMISSAO_CONHECIMENTO = '1899-12-30 

00:00:00.000' AND

FILIAL_ORIGEM = :FILIAL AND

NUMERO_CONHECIMENTO = :NUMERO AND

DATA_EMISSAO_CONHECIMENTO = :EMISSAO

Caral 17-08-2011 02:44:10

Hola
El problema me da la impresion de que esta en la sentencia sql.
En ella estas colocando la FECHA como un STRING (texto).
Código SQL [-]
''1899-12-30 00:00:00.000''
Es mejor que uses parametros y por supuesto tendras (si quieres poner esa fecha) que darle formato.
Saludos


La franja horaria es GMT +2. Ahora son las 13:33:10.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi