Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > SQL
Register FAQ Members List Calendar Guía de estilo Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04/04/2011
turbopascual5.0's Avatar
turbopascual5.0 turbopascual5.0 is offline
Miembro
 
Join Date: Feb 2011
Posts: 54
Poder: 16
turbopascual5.0 Va por buen camino
problema con where y dos condiciones and

Hola a todos. El siguiente código:

pregunta.SQL.Add('select * from linea_electro where id_el = arametro and id_el<>0' ) ;
pregunta.SQL.Add(' and estado=');
pregunta.SQL.Add('Pendiente de recepción');

error sintaxis incorrecta cerca de de

he probado todo y no consigo que funcione.

Gracias de antemano
Reply With Quote
  #2  
Old 04/04/2011
Caral's Avatar
[Caral] Caral is offline
Miembro Premium
 
Join Date: Aug 2006
Posts: 7,659
Poder: 28
Caral Va por buen camino
Hola
Lo curioso es que haces una sentencia sql y el campo id_el lo defines con dos condiciones (= a parametro y <> 0).
La logica dice que si se da un parametro se podra definir que no sea = a 0.
Bueno:
Código Delphi [-]
pregunta.SQL.text:= 'select * from linea_electro where id_el = :P1 '+
                    ' and id_el <> :P2 '+
                    ' and estado = :P3 ';
Pregunta.Params[0].value:= Dato1;
Pregunta.Params[1].value:= 0;
Pregunta.Params[2].value:= 'Pendiente de recepción';
saludos
__________________
Siempre Novato
Reply With Quote
  #3  
Old 04/04/2011
roman's Avatar
roman roman is offline
Moderador
 
Join Date: May 2003
Location: Ciudad de México
Posts: 20,269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Quote:
Originally Posted by turbopascual5.0 View Post
Hola a todos. El siguiente código:

pregunta.SQL.Add('select * from linea_electro where id_el = arametro and id_el<>0' ) ;
pregunta.SQL.Add(' and estado=');
pregunta.SQL.Add('Pendiente de recepción');
Tu sentencia SQL queda así:

Código SQL [-]
select * from linea_electro where id_el = arametro and id_el<>0
and estado=Pendiente de recepción

Aquí se ve más claro. Faltan las comillas que encierren a Pendiente de recepción

Entonces, puedes modificar la última línea de tu código así:

Código Delphi [-]
pregunta.SQL.Add('"Pendiente de recepción"');

// Saludos
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problema con condiciones nena_yei OOP 3 05/07/2010 18:09
if con 2 condiciones en un TQrexpr lucasarts_18 Impresión 2 02/01/2009 23:41
Paradox--->Condiciones lurad Tablas planas 2 19/09/2006 20:45
Condiciones Carlex SQL 7 09/08/2004 21:15
Condiciones en SQL agova SQL 5 20/07/2004 01:28


All times are GMT +2. The time now is 02:16.


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