![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
||||
|
||||
|
Cita:
// Saludos |
|
#2
|
|||
|
|||
|
Cita:
|
|
#3
|
|||
|
|||
|
Pregunta sobre Query
Roman:
cuando te referís a ejecutar la consulta, te referías a hecrlo en el código asociado donde hago esto: procedure TForm18.ListarClick(Sender: TObject); begin If Lista.Text='Código' Then begin Form21.ListadoBienUso.DataSet:=ModeloDatos.Consulta1; ModeloDatos.Consulta1.Close; ModeloDatos.Consulta1.ParamByName('ORDEN').AsString:=Modelodatos.TblMuebleCodMueble.FieldName; ModeloDatos.Consulta1.ParamByName('DESDE').AsInteger:=StrToInt(Desde.Text); ModeloDatos.Consulta1.ParamByName('HASTA').AsInteger:=StrToInt(Hasta.Text); ModeloDatos.Consulta1.Open; end; También le asigno a la variable fmSql las sentencias de la consulta SQL en éste lugar? Disculpame y gracias. Silvio.- |
|
#4
|
|||
|
|||
|
Bueno, Román se refería a algo así
Has de tener la siguiente sentencia SQL en tu Código:
SELECT Mueble.Codmueble,Mueble.Descripcion,Rubro.Nombre,Seccion.Nombre FROM Mueble INNER JOIN Rubro ON Mueble.Rubro=Rubro.CodRub INNER JOIN Seccion ON Mueble.Seccion=Seccion.Codigo WHERE :ORDEN BETWEEN :DESDE AND :HASTA ORDER BY %s Código:
ModeloDatos.Consulta1.Close;
fmSql := ModeloDatos.Consulta1.Sql.Text;
ModeloDatos.Consulta1.Sql.Text := Format(fmtSql, ['ORDEN']);
ModeloDatos.Consulta1.ParamByName('ORDEN').AsString := Modelodatos.TblMuebleCodMueble.FieldName;
ModeloDatos.Consulta1.ParamByName('DESDE').AsInteger := StrToInt(Desde.Text);
ModeloDatos.Consulta1.ParamByName('HASTA').AsInteger := StrToInt(Hasta.Text);
|
|
#5
|
||||
|
||||
|
Cita:
Otra forma podría ser olvidarse de los parámetros de SQL y colocarlos todos como parámetros de Format: Código:
SELECT Mueble.Codmueble,Mueble.Descripcion,Rubro.Nombre,Seccion.Nombre FROM Mueble INNER JOIN Rubro ON Mueble.Rubro=Rubro.CodRub INNER JOIN Seccion ON Mueble.Seccion=Seccion.Codigo WHERE ORDEN BETWEEN %s AND %s ORDER BY %s Código:
ModeloDatos.Consulta1.Sql.Text := Format(fmtSql, [Desde.Text, Hasta.Text, 'ORDEN']); ModeloDatos.Consulta1.Open; |
|
#6
|
|||
|
|||
|
Pregunta sobre Query
Cadetill:
probé como vos me detallaste, pero me da el siguiente error: 'Field in order by must be in result set' y si hago Format(fmSQL,['CodMueble']); el error es 'Parameter not set in query string'. fmSQL es de tipo String? Gracias, saludos. Silvio.- |
|
#7
|
|||
|
|||
|
Por qué no nos pones el código que usas para ver donde puede estar el error?
Acuerdate de usar las etiquetas [ code] y [ /code] (sin los espacios) |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
|