?
Solved

Open a table without its index

Posted on 1998-08-12
2
Medium Priority
?
148 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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 Month13 days, 15 hours left to enroll

801 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