Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-12-2010
calco_hugo calco_hugo is offline
Miembro
 
Registrado: jul 2010
Posts: 42
Poder: 0
calco_hugo Va por buen camino
Grid index out of range

ante todo, buenos dias, les comento algo que me esta costando resolver, tengo una aplicacion con 2 tabsheet, en el primer tabsheet hago una seleccion de datos para una consulta SQL (esto funciona perfectamente), en el segundo tabsheet tengo un dbgrid que me muestra los datos de la consulta SQL, como primer paso genero la consulta sql y me muestra los datos en el dbgrid, hasta ahi perfecto, cuando regreso al tabsheet 1 y cambio algo de la consulta e ingreso al tabsheet2, donde esta el dbgrid me da este error

Grid index out of range


alguien me podra ayudar.
desde ya gracias
hugo
Responder Con Cita
  #2  
Antiguo 15-12-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola calco_hugo.

Con esa información que das, es muy difícil dar una respuesta acertada...

. ¿ Con que base de datos estás trabajando ?
. ¿ Como haces la selección de los datos para la consulta ?
. ¿ Usas algún filtro ?
. ¿ Hay involucrada alguna relación maestro/detalle ?

Por si acaso, podrías probar haciendo un Refresh al DBGrid luego de consolidada la nueva consulta...

Saludos.
Responder Con Cita
  #3  
Antiguo 16-12-2010
Avatar de wds27
wds27 wds27 is offline
Registrado
 
Registrado: jul 2007
Posts: 9
Poder: 0
wds27 Va por buen camino
Hola.
Si es dificil detectar el problema, si estas usando adoquery o algun tipo de objeto query ¿porque no intentas cerrar la consulta antes de volver a ejecutarla?
algo así:

query1.close;
query1.sql.text:='select x from y where z';
query1.open;

Fijate que en el onshow de los tabsheet esté haciendo las aperturas en el orden correcto si es que pusiste las consultas en el evento onshow del tabsheet
Podrias explicarte mas para que te podamos ayudar a descubrir el error que causa eso.
Responder Con Cita
  #4  
Antiguo 21-02-2012
Avatar de makina
makina makina is offline
Miembro
 
Registrado: oct 2005
Ubicación: Mexico DF.
Posts: 27
Poder: 0
makina Va por buen camino
Encontre la solucion

la solucion la encontre en
http://www.experts-exchange.com/Prog..._21354684.html

by: DissasterPosted on 2005-03-17 at 09:05:54ID: 13566959
I've encontered this error before, when I executed the dataset.enable/disablecontrols with a linked grid, and between this lines I deleted some records. As far as I understand this happens because the grid does not check how many records it has after it's been re-activated.

As far as I know this is a bug that delphi has from some time, I searched all over the internet for a long time before I found the solution, and this is it:

1.- copy the file dbgrids.pas to your proyect directory (the original location is in %Program files%\Borland\Delphi7\Source\Vcl)
this is to avoid re-compiling the vcl, which by the way i don´t know how to do, if someone know, i'll be glad if they tell me how.

2.- edit the dbgrids.pas file you just copied and make the TCustomDBGrid.UpdateActive procedure look like the following lines:
Código Delphi [-]
procedure TCustomDBGrid.UpdateActive;
var
  NewRow: Integer;
  Field: TField;
begin
  if FDatalink.Active and HandleAllocated and not (csLoading in ComponentState) then
  begin
    NewRow := FDatalink.ActiveRecord + FTitleOffset;
    if (Row <> NewRow) and (NewRow < RowCount) then // <-- Modified line original line was: if Row <> NewRow then
    begin                                           
      if not (dgAlwaysShowEditor in Options) then HideEditor;
      MoveColRow(Col, NewRow, False, False);
      InvalidateEditor;
    end;
    Field := SelectedField;
    if Assigned(Field) and (Field.Text <> FEditText) then
      InvalidateEditor;
  end;
end;
that's it.. now when you recompile your proyect, it will use this unit instead of the original dbgrids.pas, and the problem will be solved.

Hope this helps
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
Grid Index out of range chino150 Varios 5 10-06-2010 02:14:19
grid index out of range ingabraham Varios 1 30-05-2008 15:57:02
Grid index out of range jmlifi Varios 29 19-10-2007 17:50:01
Grid Index out of range javicho_villa Varios 4 25-08-2006 16:30:19
Grid index out of range zugazua2001 Varios 5 22-06-2006 16:57:50


La franja horaria es GMT +2. Ahora son las 20:25:09.


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