Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 712
  • Last Modified:

BDE & SQL server RecNo

I am using a BDE table to connect to MSSQL server.
When i am trying to retrieve RecNo of the current record i get -1.
Originally, the application was written on Paradox DB and everithing as OK, but when i have moved the DB to SQL server i'he got into troubles.
Is it possible to retrieve ther current record number on SQL DB?.
TIA.
0
fish_r63
Asked:
fish_r63
  • 2
1 Solution
 
sfockCommented:
I am not completly sure why exactly this property returns wrong results in this case, but the main problem is, that a Client/Server RDBMS like the SQL Server is not comparable with a desktop database like paradox.
well you might try moveBy like

var
  curRec : Integer;
begin
  table.first;
  curRec := 1;
  curRec := curRec + table.moveBy(10);
  curRec := curRec - table.moveBy(-5);
end:

but anyhow a TTable component is alway no good idea for a client server database. In any case it will be better to migrate to TQuerys and smaller result sets and doing less work with client cursors ...

another hint would be to determine if a TADOTable makes you less problem for migration , even if it is still no good idea to us a Table component ;-) ...
0
 
fish_r63Author Commented:
TADOTable is better solution, but i have the application already written and it will be a lot of work to change the component. I am just looking fo solution without changing the components.
0
 
sfockCommented:
well i did a little bit of research and found out, that the Property RecNo Returns a value that is stored in a struckture called TRecInfo.
The Value is set in TBDEDataSet.GetRecord and it looks like this:

          case FRecNoStatus of
            rnParadox: RecordNumber := FRecProps.iSeqNum;
            rnDBase: RecordNumber := FRecProps.iPhyRecNum;
          else
            RecordNumber := -1;
          end;

FRecProps is of the type RecProps and the onlinehelp say the following:

Field     Type     Description

iSeqNum      UINT32     Specifies the sequence number of the record. Applicable if the cursor supports sequence numbers (Paradox only).
iPhyRecNum      UINT32     Specifies the record number of the record. Applicable only when physical record numbers are supported (dBASE and FoxPro only).

FRecNoStatus is of the type TRecNoStatus defined as TRecNoStatus = (rnDbase, rnParadox, rnNotSupported);

That means RecNo does only work if you have a paradox or DBase Database.

If as you say a redesign of the application is too much work for you i see only two chances for:

1. With a little bit of luck ADO provides cursors that do work "more frindly" to your needs
or
2. You reimplement this information
a. for example like shown above externaly or
b. you create a TTable descant that tracks this information by overriding the first, next, prior, last, FindFirst, FindNext, moveBy, etc methods and storing the yourself. But you have bad luch here too because the methods first, next, prior, last are static so you can't ovveride them without changing the TTable source wich will it make nessesary to recompile the bde package. So your last chance would be to add new Methods in your new TableComponent like myNext etc like this:

type
  TmyTable = class(TTable)
  private
    FmyRecNo : integer;
  public
    procedure myNext;
    procedure myPrior;
    procedure myFirst;
    procedure myLast;
  published
    property myRecNo : Integer read FmyRecNo;
  end;

implementation

procedure TmyTable.myFirst;
begin
  FmyRecNo := 1;
  self.first;
end;

procedure TmyTable.myLast;
begin
  FmyRecNo := RecordCount // i hope RecordCount works properly;
  self.last;
end;

procedure TmyTable.myNext;
begin
  self.Next;
  if not eof then Inc(FmyRecNo);
end;

procedure TmyTable.myPrior;
begin
  self.prior;
  if not bof then Dec(FmyRecNo);
end;

but of course in this case youll have to replace all TTable's with TmyTable's and replace all call of RecNo with myRecNo, allnext with myNext etc.

As you see if you'll have bad luck with the TADOTable you'll have a lot of work anyway!!!
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  RecNo desinged for Paradox, Dbase (Local Database), and it's will not work with Sql server

  Also when you working with RDBMS, you need to change the way of working with database, it's better to use TQuery than TTable, because you don't need to retrieve all the data from server to the client, you need only the required data from the server
 
 
Best regards
Mohammed Nasman
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now