Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open a table without its index

Posted on 1998-08-12
2
Medium Priority
?
149 Views
Last Modified: 2010-04-04
How can I open a dBase Table when its associate index is not present ?
Well, if I try to open a table when its index associate is not present then BDE raise an exception. An solution for this problem should be open the table at design time but I can't do it because I don't know the table's name. I know the table's names just after run some code.
Somebody help me ?
0
Comment
Question by:ara72
[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
2 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 300 total points
ID: 1361994
Hi ara72,

use DbiRegisterCallback,

an inprise example :

BDE API Examples (DbiRegisterCallback)
Registers a callback function for the client application.
--------------------------------------------------------------------------------
 
Example 1: Create a callback that handles the condition of a missing .MDX file for a dBASE file or a missing .CDX file for a FoxPro file:
//Function called by DbiRegisterCallBack
function myfunc(ecbType : CBType; iClientData : LongInt;
   pCbInfo : pCBInputDesc): CBRType; stdcall;
const
   READONLY = 'Read Only';
   FAILOPEN = 'Fail Open';  //The default
   OPENANDDETACH = 'Open and Detach';
var
  counter : integer;
begin
  case ecbtype of
    cbINPUTREQ:  //It's a callback of cbINPUTREQ type
      if pcbInfo.eCbInputId = cbiMDXMIssing then
      begin
        {
        //Simple loop to list all modes, could be used to give used
        //to give a choice
        for counter:= 0 to pcbInfo.iCount-1 do
          showmessage(pcbInfo.acbEntry[counter].szKeyWord + #13 +
                   pcbInfo.acbEntry[counter].szHelp);
        }
        for counter:=0 to pcbInfo.iCount-1 do
          if pcbInfo.acbEntry[counter].szKeyword = OPENANDDETACH then
          begin
            pcbInfo.iSelection:=counter+1;
            pcbInfo.bSave := FALSE;
            break;
          end;
      end
      else  //if
        ShowMessage('Unexpected eCbInputId');
  else  //Case
    ShowMessage('Unexpected ecbType')
  end;
end;

//Register the callback and open the table
procedure TForm1.Button2Click(Sender: TObject);
var
  cbinfo : CBInputDesc;
begin
  session.open;
  Check(DbiRegisterCallBack(
   nil,                          //Cursor (Optional)
   cbINPUTREQ,                   //Type of Callback
   longint(0),                   //Pass-through client data
   sizeof(CBInputDesc),          //Callback buffer len
   @cbinfo,                      //Pointer to callback function
   @myfunc                       //Call back fn being registered
));
   Table1.Open;

   //Unregister the callback
   Check(DbiRegisterCallBack(nil, cbINPUTREQ, 0, sizeof(CBInputDesc), nil , nil));
end;

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361995
ara72,

 an older solution :

Q:  I have a DBF table that I can't open because it is expecting an MDX (production index) file.  I lost (deleted) that file.  What do I do now?

A:  Byte 28 in the DBF file header indicates whether an MDX file is needed.  (0 = no MDX needed; 1 = MDX needed.)  Here is some code that makes the change for you.  It uses a radio group where the first item is NO MDX (element 0), and the second item is USES MDX (element 1).  This app also uses the TOpenDialog component.

procedure TForm1.Button1Click(Sender: TObject);
var
  f: file of byte;
  b: byte;
begin
  if OpenDialog1.execute then
  begin
    assignFile(f, OpenDialog1.FileName);
    reset(f);
    seek(f, 28);

    b := RadioGroup1.ItemIndex; {0 = no MDX; 1 = use MDX}
    write(f, b);
    closefile(f);
  end;
  OpenDialog1.FileName := '*.dbf'; {reset the filter}
end;

{ This code came from Lloyd's help file! }

Regards, zif.
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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

618 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