Board index » cppbuilder » RecNo problem ?

RecNo problem ?


2004-04-11 03:15:28 AM
cppbuilder51
Hi
I use RecNo in a table after filtering
RecNo is not record number of active
record, it is record number in Table
without filtering.
How can access to number of Active record
in Table after filtering ?
Thanks M.T
 
 

Re:RecNo problem ?

On Sat, 10 Apr 2004 23:45:28 +0430, "Sasan" < XXXX@XXXXX.COM >wrote:
Quote
Hi
I use RecNo in a table after filtering
RecNo is not record number of active
record, it is record number in Table
without filtering.

How can access to number of Active record
in Table after filtering ?

Thanks M.T
Don't use RecNo: applications using RecNo doesn't not scale at all if you need
to upgrade them to use true RDBMS systems.
Use the primary key instead, in order to track the row(s) you are interested.
Giuliano
 

Re:RecNo problem ?

Thanks,
How do it please tell detail or sample code.
M.T
 

{smallsort}

Re:RecNo problem ?

On Sun, 11 Apr 2004 23:30:43 +0430, "Sasan" < XXXX@XXXXX.COM >wrote:
Quote
Thanks,
How do it please tell detail or sample code.

M.T

First of all, make sure you have defined a primary key for each table in your
schema. Primary keys could be a true primary key (one column of that table
with unique values enforced by the appropriate constraint), could be a
composite key (a set of columns which generates a unique value) or, if you
can't have such condition, a surrogate primary key (normally a counter which
generates a automatic value).
When you have defined a primary key for each table, you can define a set of
foreign keys for all the tables, to define all the relationships (normally
intended as constraints) in your schema. If you are not too familiar, some
good text books regarding database design could help you in this process.
Next, whenever it's possible, it's better to use Query components instead of
table components. Depending on the DB technology you are using (BDE,
ADOExpress, DBExpress, IBExpress, etc etc): for example, using BDE, your
choice should fall with preference to a TQuery rather than to a TTable. TTable
could be more convenient for local databases but, if you plan to use RDBMS,
table components generally turn out to a greater network traffic so resulting
in slower systems. Moreover, using query components, you can create relations
(recordsets) by mean of join operators (i.e., mixing data from different
tables).
When you have the PK defined, most db technologies uses it to locate quickly
the interested records. In general, you can add indexes in order to find a row
in your relation, having a logarithmic cost access instead of linear cost
access.
You can build some sql queries with appropriate where clause, to retrieve the
needed row(s), basing the search criteria upon the primary key or an
additional index. Alternatively you can use TDataSet::Locate in order to find
the row in a multiple row relation. Even, you can try to use bookmarks in
order to keep track of the record positions in a multiple row relation: with
bookmarks, you can retrieve selectively records you have already read.
As you can see, this is a very big subject, so it's difficult to treat it,
even partially, in a group article. I suggest to read some books regarding the
subject, to have a look at BCB Database examples and to search for many
examples on google's groups.
Giuliano
 

Re:RecNo problem ?

Sasan
The following assumes a Primary Key for the table as described by Giuliano.
This is not complete code but should get you in the right direction.
TQuery *q = new TQuery;
q->Database = "MyDatabase";
q->SQL->Add("Select * from TableName");
q->Open();
q->First();
while(!q->eof)
{
Edit1->Text = IntToStr(q->FieldByName("PK")->AsInteger);
q->Next();
}
q->Close();
delete q;
Note: you'll never see the updated textbox at the speed a query would run.
This was just an example to get you on the way of using the TQuery to access
the records.
Hope this helps.
--
Phil Robertson
BSIT XXXX@XXXXX.COM
Work XXXX@XXXXX.COM
Home XXXX@XXXXX.COM
-----------------------------------------------------------
"Sasan" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks,
How do it please tell detail or sample code.

M.T