Jump to content

Recommended Posts

Posted

I have use the below code to locate a record in a table. Locally this works great, However over a browser on my LAN it is quite slow, too slow.  I have my tables indexed with less than 10,000 records.

 


var txt, sfind :string;
len:integer;
begin
   if uniEdit1.Text='' then
    exit;


 

  //goto nearest match
  with Datamodule.MYDirectoryTable
  do
  begin
    UniDBGrid1.Visible := true;
    UniDBText1.Visible := true;
     
 

    SetKey;
    FieldByName('Company').AsString := UPPERCASE(uniEdit1.Text);
    //Gotokey;  //does not work
     GotoNearest;
  end;

 

 

John P.

Posted

Hi,

 

There is No difference between VCL mode and WebMode in server side table locating !

Then you check your code for  table events (AfterScroll, BeforeScroll or ... ) or attach a sample project code (if possible with Access database or clientdataset).

 

This is better use [ try Table.DisableControl ] when you must be insert or locate table then [ finally Table.EnableControl ].

 

Regards

Posted

<< There is No difference between VCL mode and WebMode in server side table locating !

 

In my case there is a huge difference. In VLC mode the find is instant. When I create a stand alone server of the very same project and go into server mode the performance degrades. In server mode I can actually see the records in my grid I have for that table sorting, and it seems to jump around and not in a perfect A-Z order. It seems like the sorting of the table is rebuiding every time, or not tagging on the index as it should, which I do not understand the connection between the browser and database server.  I thought it might be my LAN or Antivirus software, however, I am running other client server applications using DBISAM databases without any problem whatsover.

 

 The only code I have is what I have above. I did disable and enable controls without any effect.  Any more ideas or comments?

 

John P.

Posted

From my DBase days I remember that, to change the order  a table is presented you have to :

 

1. Close the data aware components.

2. Close the table. ( not mandatory but closes the application db buffers)

3. Set the new index active

4. Open table and force "First" on the table. ( Mandatory so that the db buffers reorganise )

5. Activate the grid

6. Search on that key whatever you want.

Posted

Hi,

 

Wich database are you using and why not using a query component (or a filter option), both depending on the type of database
The example below is based on a query component and the use of MySQL

 

Normaly i do the following :

  • put a combobox, edit component and a button on the form, the combobx because the user may choose
    on wich 'field' he may search...FirstName, LastName, Address etc
  • in the editbox he enters the search info
  • the button to cancel the search and show all records

The code below contains some Dutch (because i'm dutch)text but like messages

 

The code for the Edit.KeyDown

 

 

procedure TFormProdukt.UniEdit_SearchKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  var
  SQLstring : string;
begin
  if (key=vk_return) then begin
     // naam(0)
     if UniComboBox_SearchItem.ItemIndex=0 then begin
        SQLstring:='Select * from City Where Name LIKE ''' + '%' +UniEdit_Search.Text + '%'' Order By Name';
     end;
     // Start filter
     dmMain.Produkt.SQL.Clear;
     dmMain.Produkt.SQL.Add(SQLstring);
     dmMain.Produkt.Open;
     if dmMain.Produkt.RecordCount=0 then begin
        ShowMessage('<br/>Er zijn GEEN gegevens gevonden welke' + '<br/><br/>' + 'voldoen aan het opgegeven zoek criteria.'+ '<br/>');
        SearchFilterCancel;
     end;
     if dmMain.Produkt.RecordCount>0 then begin
        UniStatusBar.Panels[1].Text:='Filter = ACTIEF';
        UniStatusBar.Panels[2].Text:='Aantal = '+intToStr(dmMain.Produkt.RecordCount);
     end;
  end;
  if (key=VK_Up) then begin
     dmMain.Produkt.Prior;
  end;
  if (key=VK_Down) then begin
     dmMain.Produkt.Next;
  end;
end;

 

The code for showing all records

 

 

procedure TFormProdukt.SearchFilterCancel;
begin
  // Tekst van het filter aanpassen
  UniStatusBar.Panels[1].Text:='Filter = UIT';
  UniStatusBar.Panels[2].Text:='';
  dmMain.Produkt.SQL.Clear;
  dmMain.Produkt.SQL.Add('Select * from City Order By Name' );
  dmMain.Produkt.Open;
  if UniEdit_Search.Focused then
     UniEdit_Search.Clear
  else
     UniEdit_Search.Text:='Zoeken naar...';
     UniComboBox_searchItem.itemIndex:=0;
end;

 

The same code for using a Filter option based on DBISAM. This code was used in a Win32 applications so the components you see a

based on Raize. You can use the code also based on uniGui and the only difference is the user of table.filter

 

 

procedure TFormTask.RzButtonEdit_searchKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
var
  SQLstring : string;
begin
  if (key=vk_return) then begin
     // Subject
     if RzComboBox_item.ItemIndex=0 then begin
        dmTables.Task.Filter:='LOWER(Subject) like LOWER('+QuotedStr('%'+RzButtonEdit_Search.Text+'%') +')';
     end;
     // Subject(1)
     if RzComboBox_item.ItemIndex=1 then begin
        dmTables.Task.Filter:='LOWER(Description) like LOWER('+QuotedStr('%'+RzButtonEdit_Search.Text+'%') +')';
     end;
     dmTables.Task.Filtered:=true;
     if dmTables.Task.RecordCount=0 then begin
        Application.MessageBox('Er zijn geen gegevens gevonden welke'+#10+'voldoen aan het opgegeven zoek criteria !', 'Informatie', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
        FilterOpheffen;
     end;
     if dmTables.Task.RecordCount>0 then begin
        cFilter:='Aangepast';
        FilterAAN;
        RzStatusPanel_Aantal.Caption:='Aantal = '+intToStr(dmTables.Task.RecordCount);
     end;
  end;
  if (key=VK_Up) then begin
     dmTables.Task.Prior;
  end;
  if (key=VK_Down) then begin
     dmTables.Task.Next;
  end;
end;

  • Administrators
Posted

I have use the below code to locate a record in a table. Locally this works great, However over a browser on my LAN it is quite slow, too slow.  I have my tables indexed with less than 10,000 records.

 

 

var txt, sfind :string;

len:integer;

begin

   if uniEdit1.Text='' then

    exit;

 

 

  //goto nearest match

  with Datamodule.MYDirectoryTable

  do

  begin

    UniDBGrid1.Visible := true;

    UniDBText1.Visible := true;

     

 

    SetKey;

    FieldByName('Company').AsString := UPPERCASE(uniEdit1.Text);

    //Gotokey;  //does not work

     GotoNearest;

  end;

 

 

John P.

 

Why don't you trace your app using Break Points and stepping through the lines and find out the exact place your code slows down.

Posted

The problem seems to be in the uniGUI grid. I removed the grid from my form and it is now very fast.  I am thinking because I customized the column order that this is slowing it down.  I am away for a day or two to try a grid in a natural field order or to try other property settings to see if that makes a difference. I could not see any other property settings that would seem to make a difference. Its seems the grid on the form is the problem for some reason, which I do not have any other events taking place.

 

And thanks to those with the tips above, which I have used simular in the past in a VCL and database environment. (I come from the days when there was dBASE III as a new release)  In this case I would like to use the grid to compilement the find as an incremental search on a character field, and build on that.  So I am wondering what would be the best way for the browser or Internet environment.

 

John P.

(Canada)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...