Board index » delphi » TDBGrid doing weird things when scrolling

TDBGrid doing weird things when scrolling

I have a Paradox Table with apx. 500,000 records and I have dynamically
created a table and some indexs at runtime.

try
    DataMod.ViewDataTable.AddIndex
        ('', 'Item Number; UOM', [ixPrimary]); //composite index
  except
    on E: EdatabaseError do
    begin
      MessageDlg(E.Message + ' Cannot create Primary Index!',
             mtWarning, [mbOk], 0);
      exit;
      end;
    end; //end execpt

  //Create index
  try
    DataMod.ViewDataTable.AddIndex
        ('Item Number', 'Item Number',[]);
  except
    on E: EdatabaseError do
    begin
      MessageDlg(E.Message + ' Cannot create alternate index!',
             mtWarning, [mbOk], 0);
      end;
    end; //end execpt

At program startup time I set the IndexName property to IndexName := ''
which should default back to the primary index but I noticed that if I take
the mouse and pull the scroll bar down thousands of records at a time on the
DBGrid (which is set to readonly) the data within the grid gets all messed
up and I get data spilling back and forth between fields.

I noticed that if I set the IndexName property to a secondary index such as
'Item Number' everthing works fine. How come my DBGrid data gets all whack
out when my primary index is set and only when scrolling real fast through
large amounts of data?

 

Re:TDBGrid doing weird things when scrolling


It is possible that the table is corrupt. You might try rebuilding it with
the table repair utility at www.rksolution.cz and see if that helps.

--
Bill

Re:TDBGrid doing weird things when scrolling


I don't think so. If I close the application and restart it the table looks
fine. If I scroll using the navigator 1 record at a time it is fine. When I
scroll down 47,000 records using the scroll bar  it is fine but if I scroll
5-10 thousand more than that the data gets mixed up from field to field and
my date field ends up with values of 00/00/0000 when they should be blank
etc. I did find a way that seems to get around this issue. Even though I
have built a primary index and set the indexname := ''; which should default
back to the primary index I added this code to the table afterscroll event:

  if ViewDataTable.State = dsBrowse then
  begin
    ViewDataTable.Refresh;
    //secondary index built with no options specified
    ViewDataTable.IndexName := 'Item Number';
  end;

When I did this the first time you scroll down more than 50,000 records  the
data flickers like it may be messed up again but then it is fine. I can then
scroll up and down 3 to 4 hundred thousand records at a time and it is fine.
It is really wierd and I have tested it multiple times and without fail if I
do not have the afterscroll event set it will mess it up and when I have the
afterscroll event logic it is fine? I also found that instead of using the
afterscroll event that if I set a secondary index active before I scroll it
is also fine. I know that my primary index is working because before I do a
FindKey I set the indexname := '' and FindKey works great........

"Bill Todd (TeamB)" <billtodd...@nospam.qwest.net> wrote in message
news:3b029413_1@dnews...

Quote
> It is possible that the table is corrupt. You might try rebuilding it with
> the table repair utility at www.rksolution.cz and see if that helps.

> --
> Bill

Other Threads