Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 26-09-2006
Avatar de Goyo
Goyo Goyo is offline
Miembro
 
Registrado: feb 2006
Posts: 89
Poder: 19
Goyo Va por buen camino
implemente lo que me indicaste, solo cambiando el componente ADOQuery por Query y quedo de la siguiente manera:

Código Delphi [-]
procedure TFrmImprimirVehiculo.SpeedButton1Click(Sender: TObject);
begin
 if (DBNumeroVehiculo.Text <> 'Todos')  then
    Begin
     FrmReporte1:=TFrmReporte1.Create(self);
     FrmReporte1.Query1.SQL.Add('SELECT NumeroVehiculo');
     FrmReporte1.Query1.SQL.Add('FROM BitacoraVehiculos RIGHT JOIN Vehiculos ON BitacoraVehiculos.NumeroVehiculo = Vehiculos.NumeroVehiculo');
     FrmReporte1.Query1.SQL.Add('WHERE TbVehiculos.NumeroVehiculo = '+DBNumeroVehiculo.Text);
     FrmReporte1.Query1.Open;
     if RadioGroup1.ItemIndex = 0 then FrmReporte1.QuickRep1.Print
        else FrmReporte1.QuickRep1.Preview;
        FrmReporte1.Free;
     end;
 end;

me marca un error al ejecutarlo y no me muestra nada
Responder Con Cita
  #2  
Antiguo 26-09-2006
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Que error?
Responder Con Cita
  #3  
Antiguo 26-09-2006
Avatar de Goyo
Goyo Goyo is offline
Miembro
 
Registrado: feb 2006
Posts: 89
Poder: 19
Goyo Va por buen camino
Unhappy

que no encuentra la tabla BitacoraVehiculos.

De hecho tengo dos tablas de paradox: Vehiculos (que es catalogo principal de vehiculos) y BitacoraVehiculos (que es donde se graban todos sus gastos de los vehiculos).
Responder Con Cita
  #4  
Antiguo 26-09-2006
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Aqui Hay varias cosas.
Primero si copiaste y pegaste el codigo, hay un error fijate:
El tuyo:

Código Delphi [-]
procedure TFrmImprimirVehiculo.SpeedButton1Click(Sender: TObject);
begin
 if (DBNumeroVehiculo.Text <> 'Todos')  then
    Begin
     FrmReporte1:=TFrmReporte1.Create(self);
     FrmReporte1.Query1.SQL.Add('SELECT NumeroVehiculo');
     FrmReporte1.Query1.SQL.Add('FROM BitacoraVehiculos RIGHT JOIN Vehiculos ON BitacoraVehiculos.NumeroVehiculo = Vehiculos.NumeroVehiculo');
     FrmReporte1.Query1.SQL.Add('WHERE TbVehiculos.NumeroVehiculo = '+DBNumeroVehiculo.Text);
     FrmReporte1.Query1.Open;
     if RadioGroup1.ItemIndex = 0 then FrmReporte1.QuickRep1.Print
        else FrmReporte1.QuickRep1.Preview;
        FrmReporte1.Free;
     end;
 end;

El mio ya con query:

Código Delphi [-]
procedure TFrmImprimirVehiculo.SpeedButton1Click(Sender: TObject);
begin
If (DBNumeroVehiculo.Text <> 'Todos')  then
  Begin
FrmReporte1:=TFrmReporte1.Create(self);
FrmReporte1.Query1.SQL.Add('SELECT NumeroVehiculo');
FrmReporte1.Query1.SQL.Add('FROM TbBitacora RIGHT JOIN TbVehiculos ON TbBitacora.NumeroVehiculo = TbVehiculos.NumeroVehiculo ');
FrmReporte1.Query1.SQL.Add('WHERE TbVehiculos.NumeroVehiculo = '+DBLookupComboBox1'');
FrmReporte1.Query1.Open;
If RadioGroup1.ItemIndex = 0 then FrmReporte1.Print
else FrmReporte1.Preview;
finally
FrmReporte1.Free;
end;
end;
end;

Revisa el la parte:

Código Delphi [-]

FrmReporte1.Query1.SQL.Add('FROM BitacoraVehiculos RIGHT JOIN Vehiculos ON BitacoraVehiculos.NumeroVehiculo = Vehiculos.NumeroVehiculo');
la tabla BitacoraVehiculos
tiene un campo NumeroVehiculo
y
la tabla Vehiculos tambien ?
Recuerda que no veo las tablas ni los campos, es dificil adivinar.
Ademas te falta el finally, si no simplemente no lo ejecuta.
Prueba, revisa y me dices
Saludos
Responder Con Cita
  #5  
Antiguo 26-09-2006
Avatar de Goyo
Goyo Goyo is offline
Miembro
 
Registrado: feb 2006
Posts: 89
Poder: 19
Goyo Va por buen camino
aqui te muestro los campos de cada tabla para que te des una idea mejor... te recuerdo que son bases de datos de Paradox

Tabla: Vehiculos
NumeroVehiculo - tipo A de 3
Placas - tipo A de 15
Marca - tipo A de 15
Tipo - tipo A de 10
Modelo - tipo N
NumeroSerie - tipo A de 20
Cilindros - tipo N
ResguardoA - tipo A de 60

Tabla: BitacoraVehiculos
Clave - tipo + (autonumerica) - este campo no lo uso
NumeroVehiculo - tipo A de 3
FechadeServicio - tipo D
ConceptoReparacion - tipo M de 50
ConceptoServicio - tipo M de 50
DiasdeComision - tipo A de 16
LitrosGasolina - tipo A de 9
NumeroFactura - tipo A de 16
Importe - Tipo N
ImporteTotal - Tipo N
Responder Con Cita
  #6  
Antiguo 26-09-2006
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Pon esto:
Código Delphi [-]
procedure TFrmImprimirVehiculo.SpeedButton1Click(Sender: TObject);
begin
If (DBNumeroVehiculo.Text <> 'Todos')  then
  Begin
FrmReporte1:=TFrmReporte1.Create(self);
FrmReporte1.Query1.SQL.Add('SELECT NumeroVehiculo');
FrmReporte1.Query1.SQL.Add('FROM BitacoraVehiculos RIGHT JOIN Vehiculos ON BitacoraVehiculos.NumeroVehiculo = Vehiculos.NumeroVehiculo ');
FrmReporte1.Query1.SQL.Add('WHERE Vehiculos.NumeroVehiculo = '+DBLookupComboBox1'');
FrmReporte1.Query1.Open;
If RadioGroup1.ItemIndex = 0 then FrmReporte1.Print
else FrmReporte1.Preview;
finally
FrmReporte1.Free;
end;
end;
end;
Seguro TbBitacora, no lo encuentra.?
Prueba y Me dices
Saludos
Responder Con Cita
  #7  
Antiguo 26-09-2006
Avatar de Goyo
Goyo Goyo is offline
Miembro
 
Registrado: feb 2006
Posts: 89
Poder: 19
Goyo Va por buen camino
Angry

que tal Caral. mira lo implemente de esta otra forma, solo que me marca error, el mismo error implementando la forma que tu me sugeriste...

Código Delphi [-]
procedure TFrmImprimirVehiculo.SpeedButton1Click(Sender: TObject);
 var consulta : string;
begin
  If (DBNumeroVehiculo.Text <> 'Todos')  then
    Begin
    try
     FrmReporte1:=TFrmReporte1.Create(self);
  consulta:='SELECT NumeroVehiculo FROM BitacoraVehiculos RIGHT JOIN Vehiculos ON BitacoraVehiculos.NumeroVehiculo = Vehiculos.NumeroVehiculo WHERE Vehiculos.NumeroVehiculo ='+chr(39)+DBNumeroVehiculo.Text+chr(39);
  FrmReporte1.Query1.SQL.Add(consulta);
  FrmReporte1.query1.Active:=False;
  FrmReporte1.query1.Active:=True;
    If RadioGroup1.ItemIndex = 0 then FrmReporte1.QuickRep1.Print
           else FrmReporte1.QuickRep1.Preview
           finally
           FrmReporte1.QuickRep1.Free;
        end;
   end;
end;

te comento que ruve que ponerle Try para que pueda funcionar el Finally , asimismo, te comento que escribi esto porque asi se llama mi componente DBLookupComboBox1: chr(39)+DBNumeroVehiculo.Text+chr(39) si no le ponto el .text al final me marca error, al igual que cuando llamo el reporte en FrmReporte1.QuickRep1.Print, FrmReporte1.QuickRep1.Preview y FrmReporte1.QuickRep1.Free, me marca un error que desconoce el campo preview y free. y el error que me marca al final... de hecho haciendo estas correcciones al igual que al tuyo, me marca este error...

project bitacoravehiculos.exe tabla bitacoravehiculos
Responder Con Cita
  #8  
Antiguo 26-09-2006
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
No tengo ni idea del porque.
A mi me funciona perfectamente como te indique, creo que tendras que revisar mas el codigo para entender el error, si esta en mis manos te ayudo con mucho gusto.
Saludos
Responder Con Cita
  #9  
Antiguo 26-09-2006
Avatar de Goyo
Goyo Goyo is offline
Miembro
 
Registrado: feb 2006
Posts: 89
Poder: 19
Goyo Va por buen camino
mira Caral, ahora creo que puedo explicarte: el error que me marca es que dice que no encuentra la base de datos o la tabla BitacoraVehiculos.. yo tengo mi programa en c:\Mis Documentos\BitacoraVehiculos\
y mis datos osea mis tablas en : c:\Mis Documentos\BitacoraVehiculos\Datos

el error que me marca es el siguiente:


project BitacoraVehiculos.exe raides exception class DBEngineError with message 'table does not exist.
File o directory does not exist
File c:\Mis Documentos\BitacoraVehiculos\BitacoraVehiculos.db
File c:\Mis Documentos\BitacoraVehiculos\BitacoraVehiculos.dbf
File c:\Mis Documentos\BitacoraVehiculos\BitacoraVehiculos.txt
File c:\Mis Documentos\BitacoraVehiculos\BitacoraVehiculos'. process stoped. Use step or run to continue.

y disculpa tanta molestia...
saludos
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error en Consulta de tablas creadas en tiempo de ejecucion javicho_villa Varios 1 02-02-2006 17:14:28
Crear tablas en tiempo ejecucion noe Firebird e Interbase 1 29-09-2005 16:50:41
Asignar la ruta de tablas en tiempo de ejecucion tortelini Varios 2 19-03-2005 12:13:53
Creación de tablas temporales en ADO en tiempo de ejecución Athalon Conexión con bases de datos 1 27-04-2004 13:20:20
tablas con filtro davidgaldo Conexión con bases de datos 2 20-02-2004 19:09:09


La franja horaria es GMT +2. Ahora son las 22:18:08.


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
Copyright 1996-2007 Club Delphi