?
Solved

BDE & SQL server RecNo

Posted on 2003-03-08
4
Medium Priority
?
697 Views
Last Modified: 2013-11-23
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
Comment
Question by:fish_r63
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:sfock
ID: 8093408
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
 

Author Comment

by:fish_r63
ID: 8093466
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
 
LVL 3

Accepted Solution

by:
sfock earned 200 total points
ID: 8093578
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
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8093775
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question