Link to home
Start Free TrialLog in
Avatar of DPomeroy
DPomeroy

asked on

database connection

I am trying to access create a Paradox database with an
SQL statement.  I don't want to use any of the database components.  Can I code all of the connection properties and then use the SQL create command?  After I create then I need to access the database with SQL commands.  I can't seem to find anything on this process in any of the supplied Delphi books or in any of the books at my local book store.  Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of hpierson
hpierson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hpierson
hpierson

Here is an example (again from the BDE Help file)

Create a table on disk by using a given SQL statement.

The filename is also passed as a parameter. The function returns the number of rows in the result table. This example uses the following input:  
      fDbiQExec(hNewCur, 'QUERY.DB', 'SELECT * FROM TEST;');

Function fDbiQExec(hTmpDb: hDBIDB; TblName, SQL: String): Longint;
var
  hStmt: hDBIStmt;
  hQryCur, hNewCur: hDBICur;
  iRecCount: LongInt;
begin
  hQryCur := nil;
  hNewCur := nil;
  hStmt := nil;

  try
    Check(DbiQAlloc(hTmpDb, qrylangSQL, hStmt));
    Check(DbiQPrepare(hStmt, PChar(SQL)));
    Check(DbiQExec(hStmt, @hQryCur));
    Check(DbiQInstantiateAnswer(hStmt, hQryCur, PChar(TblName), szPARADOX,
                                      true, hNewCur));

    Check(DbiGetRecordCount(hNewCur, iRecCount));
    Result := iRecCount;
  finally
    if hStmt <> nil then
      Check(DbiQFree(hStmt));
    if hNewCur <> nil then
      Check(DbiCloseCursor(hNewCur));
  end;
end;
Avatar of DPomeroy

ASKER

I sure can't find that BDE help file in my system.  I have Delphi 2.0.  I will keep trying.  It seems to me that there should be something written in some book somewhere that would show me how to do this.  It took about 3 minutes for me to figure it out in Visual Basic.  There documentation is so much better than Borlands.  Its a shame.