DBGrid - Table Filter Problem

Hi everyone,
I am a newbie both on this forum and Borland C++ and hope you can help me to figure out the problems which I encountered during my project.

Here we go,
I wrote a program that reads SysLog messages and store it in a database.These log messages are highlighted to the user by means of DBGrid, Datasource and Table controls.

My aim is [italic]to write a filter for the table dataset[/italic] which searches the log messages and only shows the entries which include this keyword.To make myself clear,suppose that our keyword is "whitepearl" and we want to show only the entries in DB that includes this keyword(3rd and 5th one)

I tried to use "[b] LOG = '*%s*' "[/b] as a table filter expression with two wildcards but it didn't worked.What am I doing wrong?

[u]LOG[/u]
1)ZepyhR sent a message to Cedric.
2)System alert on #2334
3)Logging to the [b]whitepearl[/b]
4)Retrieval of the tuple id
5)OK from [b]whitepearl[/b]
6)Hangout by sender

Note: Borland Builder v.5 is used

Comments

  • This is how i search a database and put the items in a grid, It might be longer then somes but it work great :D Dont mind the money part it was there for adding values in hte database for each item that was found. If you have any questions ask cheers squills


    [CODE]
    void __fastcall TForm6::FormShow(TObject *Sender)
    {
    int i = 1;
    int p = 0;
    int money =0;
    Edit3->Text = Form1->ExistingVehicleList->Text; //This is what iam searching what ever is in that textbox
    Table1->First(); //starts at top of DAtabase
    do
    { if(Table1->Fields->Fields[4]->AsString == Edit3->Text)//if the text(searched item) = the item in field 4 which is my list of items name
    {
    StringGrid1->Rows[0]->CommaText = "ProPM Item_Repaired Descreption Cost Date";
    StringGrid1->RowCount = i +1;
    //All this stuff inputs the info into the cells on the table from the database as long as field 4 is equeal to my search text
    StringGrid1->Cells[1][i] = Table1->Fields->Fields[0]->AsString;
    StringGrid1->Cells[2][i] = Table1->Fields->Fields[1]->AsString;
    StringGrid1->Cells[3][i] = Table1->Fields->Fields[2]->AsInteger;
    StringGrid1->Cells[4][i] = Table1->Fields->Fields[3]->AsString;
    i=i+1;
    money = money + Table1->Fields->Fields[2]->AsInteger;
    p = 1;
    }
    Table1->Next(); //goes to the next database field
    } while(Table1->Eof == false) ; //searches database till it the end of hte database
    if(p == 0)
    StringGrid1->RowCount = 0;

    Edit1->Text = StringGrid1->RowCount - 1;
    Edit2->Text = money;

    DBNavigator->BtnClick(nbInsert);

    }
    [/CODE]
  • This is how i search a database and put the items in a grid, It might be longer then somes but it work great :D Dont mind the money part it was there for adding values in hte database for each item that was found. If you have any questions ask cheers squills


    [CODE]
    void __fastcall TForm6::FormShow(TObject *Sender)
    {
    int i = 1;
    int p = 0;
    int money =0;
    Edit3->Text = Form1->ExistingVehicleList->Text; //This is what iam searching what ever is in that textbox
    Table1->First(); //starts at top of DAtabase
    do
    { if(Table1->Fields->Fields[4]->AsString == Edit3->Text)//if the text(searched item) = the item in field 4 which is my list of items name
    {
    StringGrid1->Rows[0]->CommaText = "ProPM Item_Repaired Descreption Cost Date";
    StringGrid1->RowCount = i +1;
    //All this stuff inputs the info into the cells on the table from the database as long as field 4 is equeal to my search text
    StringGrid1->Cells[1][i] = Table1->Fields->Fields[0]->AsString;
    StringGrid1->Cells[2][i] = Table1->Fields->Fields[1]->AsString;
    StringGrid1->Cells[3][i] = Table1->Fields->Fields[2]->AsInteger;
    StringGrid1->Cells[4][i] = Table1->Fields->Fields[3]->AsString;
    i=i+1;
    money = money + Table1->Fields->Fields[2]->AsInteger;
    p = 1;
    }
    Table1->Next(); //goes to the next database field
    } while(Table1->Eof == false) ; //searches database till it the end of hte database
    if(p == 0)
    StringGrid1->RowCount = 0;

    Edit1->Text = StringGrid1->RowCount - 1;
    Edit2->Text = money;

    DBNavigator->BtnClick(nbInsert);

    }
    [/CODE]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion