Common Technical Questions and Answers to Delphi 3 and BDE/SQL Links 4.x - Database


DATABASE SECTION


New MSACCESS Native Driver


Q: "General SQL Error -2147221164 Table: Alias:<Alias Name>" error: I get this error when I try and open a MSACCESS database. What is the problem?

A: This problem seems to be closely related to a DAO DLL versioning problem. The easiest way to resolve this is to un-install Office 97 from Control Panel | Add/Remove Programs. There is information related to this problem in Microsoft's knowledge base # Q141294.


Q: "Syntax error in query. Incomplete query clause" error: I get this error when I run a query against a table with a space in the table name. I have double quotes around the name but it still does not work. What am I doing wrong?

A: You need to change the double quotes " " to brackets [ ]
Example:


Q: "Can't delete or change record. Since related record exists in table ='xxx', referential integrity rules would be violate" error: What causes this error and how do I get around the problem?

A: The problem is that referential integrity is currently not supported with the MSACCESS driver. Borland recognizes this as a problem and is working on a solution. Currently, the only workaround is to remove referential integrity from the MSACCESS tables. You can see this behavior with Access 95 by changing the RI value in the master table to the same value and trying to post. Access 97 has fixed this problem.


Q: Alternate security databases: Is it possible to use alternate security databases other than the one specified in the registry?

A: Currently, the BDE can only use the security database specified in the registry. Borland recognizes this as a problem and is working on a solution.


Q: DAO necessities: What other software do I need to access Microsoft Access databases and tables?

A: You must have Microsoft's DAO version 3.0 drivers installed. The Access driver does not support DAO 3.5 (Access 97). If you upgrade Access 95 to Access 97, DAO 3.0 still resides on your machine, so the driver will function correctly. If you install Access 97 with no prior version of Access 95, the driver will not function.


Q: Multi-threaded applications: Can I use the MSACCESS driver to create multi-threaded applications?

A: Yes and No. DAO 3.0 is not thread safe so all applications using DAO (including Borland's MSACCESS driver) must access the database through the main process' thread. The application can still use threads as long as the threads do not do any database operations with the MSACCESS driver.


Q: Current limitations: What restrictions are there on the MSACCESS driver?

A: BCD (binary coded decimal) support is not available. Key-violation tables cannot be created with DbiAddIndex. (All other DbiAddIndex functionality is supported.) QBE, heterogeneous queries, and queries using the local SQL engine are not supported. In the SDK, DbiDoRestructure and DbiRegenIndex are not available. Opening a table when TTable.Exclusive is set to True prevents the user from opening that table again, even in same session.


Q: BLObs as SQL input parameters: Can BLObs be used as input parameters to queries and stored procedures?

A: Yes. Before BDE 4.0, no BLOb could be used as an input parameter.


Q: Driver deployment: What other files need to be included with applications using the MSACCESS driver?

A: Along with the BDE core DLLs, you need IDDAO32.DLL. This is BDE's MSACCESS driver file. You will also need to distribute DAO 3.0 on all machines using the MSACCESS driver. Before deploying an application, verify that you have distribution rights for DAO and the JET engine. The BDE MSACCESS driver can be freely distributed.


Q: Alternative system database: How can I specify a different system database other than the default?

A: With BDE 4.00, there is no setting to change the system database. The MSACCESS driver uses the system database. This is a known problem and will more than likely be fixed with a later version of BDE.


Q: "Cannot Load IDAPI Service Library" error: What does this error mean and how can I resolve it?

A: If Access 95 or Office 95 was not used to load the DAO 3.0 engine on the machine, the cause is a missing registry entry. To fix this, place the folloing entry in the registry:

Another cause of this error is if the registry is set to read only. The only workaround for this cause is to either make the registry read / write, or make that particular entry read / write.

New FoxPro Native Driver


Q: "Translate error, value out of bounds" error with blank date fields: What causes this error and how do I get around the problem?

A: Fox Pro stores one of three things in a date field:

  1. An actual date (ex 19970727 is 7/27/1997)
  2. 8 Spaces (ASCII 20)
  3. 8 Zeros (ASCII 30)
All of these are acceptable to Fox Pro. The Fox Pro driver for the BDE only accepts 1 & 2 as valid dates and returns a translate error for the 3rd (8 ASCII zeros) as it doesn't consider this as a valid date. To fix the problem, restructure the date field to a char field and then restructure the table again changing the char filed back to a date field. This translation writes back only valid values to the date field and fixes the problem.

New Borland Database Engine (BDE) 4.0 features


Q: BDE network installation: I want to put the entire BDE DLLs and configuration files on our LAN. Is this possible and is there an easy way to setup the clinet machines? I don't know what the registry settings are for the BDE.

A: There is a BDE network installation example that allows a user to setup the BDE and SQL Links on a client machine without having to install the BDE and SQL Links to the client. Registry entries are placed into the client machines so that the client can access a network version of the BDE. Two programs are included: one which helps configure the .INI file that is necessary to create the registry entries, and another program that shows how the methods work to create the registry entries. This is not officially supported by Borland. It was developed by Developer Support to help in BDE network installations. NOTE: Using this example or any method within it, does not violate your Borland No Nonsense License Agreement. These exmaples are compiled with Delphi 3.


Q: BDE configuration utility: Is there a new BDE configuration Utility?

A: Yes. The BDE Configuration Utility (BDECFG32.EXE) is updated and is now the BDE Administrator (BDEADMIN.EXE). The administrator now shares the same "look and feel" of Delphi's database explorer.


Q: FoxPro support: What are the capabilities of the new FoxPro driver?

A: The dBASE (STANDARD) driver now includes support for FoxPro version 2.0, 2.5, and 2.6 compressed index (.CDX) and BLOb (.FPT) files, letting you open and create FoxPro 2.5 tables.


Q: Microsoft Access support: What are the capabilities of the new Access driver?

A: If you have a version of the Microsoft JET engine (included with Microsoft Access and FoxPro) installed on your system you can now use the BDE to open or create Microsoft Access tables using the MSACCESS driver. Please see New MSACCESS Native Driver for more infromation.


Q: SQL Parameter binding: What type of parameter binding is supported?

A: BDE now supports parameter binding for BLObs and strings longer than 255 characters except for the MSACCESS driver. Please see BLObs as SQL input parameters for more infromation.


Q: New functions: Are there any new BDE API functions?

A: Yes. DbiAddDriver and DbiDeleteDriver let you add and remove ODBC drivers from the current BDE configuration or session. The BDE now automatically adds ODBC drivers and data sources as BDE aliases to the active session when they aren't currently stored in the configuration file. Also, please look at the BDE API Examples page for examples not found in the BDE32 help file.


Q: ODBC Support: What version of ODBC is supported?

A: Versions 3.x and earlier are now supported by BDE 4.0.


Microsoft SQL Link Driver


Q: Performance with two or more queries: Using MSSQL, or Sybase for that matter, why does a second simple select query run more slowly than a preceding query.

A: MS SQL has a "pending result sets" behavior where the 1st query will only retrieve a small set of records (usually enough to fill a grid or any other data aware controls), and there will be a pending result set. The second query causes that pending result set to be retrieved. This can be tested by closing the first query before running the second or connecting each query to a TDatabase. The BDE uses a "special" connection type that is restricted to one per database connection. When a second query is run within the same database connection, the BDE must fetch and cache the previous query's records before starting the next query.
Suggestions:

  1. Close the first query before opening the second
  2. Use multiple databases, one per query
  3. Use a more restrictive where clause to limit the number of records
  4. Use a more restrictive domain result to retrieve only the fields you need

Q: "Memo too large" error with MSSQL on NT4 with Service Pack 3: Using BLOB I/O an error, 'Memo Too Large' is returned. The error is: General SQL Error: 7134, unmapped [text: text table and table reference by the text pointer disagree.]. This is not a problem if the table does not contain a unique index. In this case all BLOB information is retrieved through the execution of the query. What does this error mean and how can I resolve it?

A: A fix to MSSQL server is available from Microsoft as an Intel Patch or an Alpha Patch
NOTE: The password to use when extracting the files is "6.50.265" (without the quotation marks). To extract with the password, the syntax is: sql265i.exe -s6.50.265


InterBase SQL Link Driver


Q: "Cannot Load IDAPI Service Library" error: What does this error mean and how can I resolve it?

A: This error occurs when MSVCRT40.DLL is not presant on the client machine.


Oracle SQL Link Driver


Q: "Vendor initialization failure: ORANT71.DLL" error: When attempting a connection to Oracle using the BDE Oracle SQL Links driver, why am I getting the error, Vendor initialization failure: ORANT71.DLL, when the driver's Vendor Init parameter is set to ORA73.DLL [or ORA72.DLL]?

A: The BDE always searches the path first for the DLL specified in the Vendor Init parameter and if that fails, the BDE searches, by default, for ORANT71.DLL. Thus the Vendor Init error means that the BDE failed to find and load the DLL you specified and ORANT71.DLL.


Q: "External Exception C0000008" or "Access Violation" error with 2.3.3 SQL NET client: I get an Access Violation with Delphi 3 and an External Exception error with Delphi 2 when connecting to an Oracle server when in Delphi's IDE or Turbo Debugger with NT4. If I run the application alone, it executes correctly. How do I get around the problem?

A: Borland has determined that this is a problem with SQL NET 2.3.3. Oracle also recognizes this as a SQL NET problem. There are a couple of workarounds:

  1. Rename or remove the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\OTRACE73 NOTE: This is the solution that Oracle support recommends!
  2. Start Oracle's Installer and remove the "Oracle Trace Collection Serveces 7.3.3.x.x"
  3. Turn off Integrated Debugging in Delphi's IDE
  4. Use an Oracle SQL NET that is older than 2.3.3
Also look at Sybase's "External Exception C0000008" error on application exit for more information.

Sybase SQL Link Driver


Q: SELECT INTO statment returning error "ct_cursor(CLOSE); user api layer: external error: A cursor must be opened before this command type can be intialized." (graphic) What is wrong and how do I get around the problem?

A: The Sybase CTLIB client will always parse a passthrough sql statement weather or not we (Delphi, BDE, SQL Links, etc.) issue an 'open' or 'exec'. If a SELECT is found to be the FIRST word, it (Sybase CTLIB) will try to create a cursor hence the error message. There is a workaround. Place a comment in front of the SQL text like so: change select * into #temptable from oldtable to /**/select * into #temptable from oldtable.


Q: "External Exception C0000008" error on application exit: I get an External Exception error in Delphi when connecting to Sybase server when in Delphi's IDE or Turbo Debugger with NT4 running the 10.0.4 Sybase client. If I run the application alone, it executes correctly. How do I get around the problem?

A: In NT4.0 anything that is being debugged with any debugger will cause the OS to report exceptions that would otherwise be ignored. "External Exception C0000008" one of those types of errors. Changing the Sybase client version will solve the problem. You can either move back to the 10.0.3 client or try using Sybase's EBF (Emergency Bug Fix)# 7181, and/or 7264. EBFs can be found at the Sybase EBF download area


Remote Datasets


Q: "Invalid class string" error during connect: I'm specifying the ServerName for my RemoteServer, and when trying to connect I get "Invalid class string". What's wrong?

A: You're not specifying the ServerGUID. You always need the ServerGUID. The ServerName, however, is optional.


Q: "Cannot load IDAPI service library" error during connect: I try to connect to my Remote Server and I get a "Cannot load IDAPI service library" error message on the client machine. What is wrong?

A: This error is being propagated from the server where the actual problem resides. This error is a good indication that IDPROV32.DLL has not been properly installed on the server. Copy this file to the BDE directory on the server and register it through the use of a proper tool like TRegSvr.exe or RegSrv32.exe.


Q: Remote datasets for multiple clients: My dataset works fine when only one client connects to the dataset; What do I have to do in order to make it work for multiple clients?

A: For your TSession component, set AutoSessionName to True and for your TDatabase component, set HandleShared to True.


Q: "Error reading Database1.SessionName. Duplicate database name 'MyDB'." error: What is wrong?

A: For your TDatabase component, set HandleShared to True.


Q: "Error reading Session1.SessionName. Duplicate session name 'MySession'." error: What is wrong?

A: For your TSession component, set AutoSessionName to True.


Q: Client application hangs: What is wrong?

A: Most likely your application server has raised an exception (on the server machine) that isn't being handled correctly. You have to add exception handling to your application server. It could also be because your server is hung for other reasons and can't service your request.


Q: "Provider name was not recognized by the server" error: What is the cause and how do I fix this error?

A: The problem can be caused by making changes to the server, but not rebuilding the entire project, so the EXE and TLB were out of sync. Simply rebuild the server with 'Build All'.


Q: "Could not find interface IDataBroker in type library" error: What is the cause and how do I fix this error?

A: DataBroker is defined in the "Borland standard VCL type library", which is found in bin\stdvcl32.dll. Use REGSVR32.EXE or TREGSVR to register the type library. This may have failed in the install.


Quick Reports


Q: Blank form at design or run time: Using QuickReports 2, I have a report with only a title band and some QRLabels, at design or run time I can not print or preview the form (It is blank). What is wrong?

A: Most likly, QuickReport doesn't think you any Data to print or preview. At runtime you can tell QR to print using this techinque:
On the Report's OnNeedData event, add this code:

If Form1.tag = 0 then
begin
   MoreData := True;
   Form1.Tag := 1;
end else
  MoreData := False;
This tells the QR component that it got data, go ahead and print. Then the component on the next time into the event to stop - no longer needs data avoiding an infinite loop. Of couse Form1's tag property is simple being used as a flag, thus can be replaced by any other flaging scheme.

Q: Saving a QuickReport custom preview to text: How do I save a QuickReport custom preview to text?

A: Add QREXTRA to your uses clause and the following code to your "Save button" in your custom preview:

procedure TfrmPreview.ToolButton3Click(Sender: TObject);
begin 
  frmReport.QuickRep1.ExportToFilter
       (TQRAsciiExportFilter.Create('c:\report.txt'));
end;

Q: TQRExpr does not recognize DisplyFormat settings: What is the easiest workaround?

A: The workaround is to simply get rid of the TQRExpr component and use a TQRDBText component instead. This component honors DisplayFormat settings.


Miscellaneous


Q: Using the lookup method with multiple columns: How do I use the Lookup method to return values from multiple columns?

A: The result is a variant array -- one index to the array for every column specified in the KeyValues parameter:

procedure TForm1.Button1Click(Sender: TObject);
var
  MyResults: Variant;
  MyKeyFields, MyKeyValues: String;
  MySearchForValue: Integer;
begin
  MyKeyFields := 'CustNo';
  MySearchForValue := 1351;
  MyReturnColumns := 'Company;Addr1';
  MyResults := Table1.Lookup(MyKeyFields, MySearchForValue, MyKeyValues);
    if not VarIsNull(MyResults) then
      ShowMessage('Company: ' + MyResults[0] + '   Address: ' + MyResults[1]);
  {  With DBDemos data this returns
    "Company: Sight Diver   Address: 1 Neptune Lane" }
end;

Q: Hetergenious joins: How do I join files from differing alias (heterogeneous joins) using a SQL statment?

A:

SELECT A.ITEMNO, B.VENDORNO
FROM ":DBDEMOS:ITEMS" A, ":IBLOCAL:VENDORS" B
WHERE A.VENDORNO = B.VENDORNO

Q: "Insufficient memory for this operation" error: Whenever I attempt to open many query or table cursors, I finally reach a point when I get an error, "Insufficient memory for this operation". What do I do?

A: First, you should read the technical document on Some current internal limits of BDE. This document will tell you what most of absolute BDE limits are.

IMPORTANT: If your application is not reaching one of the limits covered in TI2751 and you are also getting the above error message, most likely the SHAREDMEMSIZE setting in the BDE will solve your problem. This setting will allow you to increase the BDE's internal object memory pool. A setting between 4096 and 8192 should be more than plenty.


Q: Sybase SQL Anywhere update mode: I am using Sybase SQL Anywhere version 5.5 and I want to be able to set the UpdateMode for my dataset (Query or Table) to be upWhereKeyOnly. When I watch SQL Monitor to see the update logic used, it appears to act like UpdateMode is set to upWhereAll. Why can't I update by key only?

A: This problem has to do with the fact that primary key indexes are not surfaced by SQL Anywhere in the BDE. If you run the stored procedure sp_statistics with your table name as a parameter(ex. sp_statistics customer), it should return all indexes on the table specified. Doing this you will see that the index on the primary key doesn't surface a index name.

The way to correct this is by configuring your DSN for SQL Anywhere to allow keys to be seen. This is done by checking the check box titled Microsoft Applications(Keys in SQL statistics) in the Additional Connection Options Section of the ODBC Configuration dialog for SQL Anywhere. After setting this, when you connect to your SQL anywhere database you will be able to see primary keys and UpdateMode will work as expected.


Q: ALTER TABLE statment on a Paradox table removes all passwords: When adding or removing fields with the ALTER TABLE SQL statment, all passwords on the table are lost. What can I do about it?

A: Borland recognizes this as a problem and is working on a solution. Currently, the only workaround is to use DbiDoRestructure to add and remove fields. Here are some examples for DbiDoRestructure.


Q: MaxLength property of a DBEdit is not automatically set to the underlying field length: In Delphi 1.0 and 2.0, the TDBEdit control would automatically set the max field length (MaxLegth) and wouldn't allow you to enter more characters than the size specified for the TField Object. Why has Delphi 3 remove this "feature"?

A: This new behavior allows you to set the value different than the field size. Delphi 1 and Delphi 2 overrided a change and put back the field size length. In Delphi 3 though, the maximum length is set, by default, to zero and will allow you to specify and enter any MaxLength for a TDBEdit, but it only writes as many characters to the database as the actual TField size property allows.


Q: "Interface mismatch. Engine version different" error: This error occurs when I start my Delphi 3 application. What is wrong?

A: All Delphi 3 database applications require that BDE 4.0 or greater is on the system. If you distribute this type of application, you must also distribute BDE version 4.0 or greater.


Q: Access violation in Delphi IDE when calling a C/C++/Delphi BDE API DLL: How do I resolve this access violation?

A: There is an undocumented BDE API function called DbiDllExit which can be prototyped the same as DbiExit. Place the prototype in your idapi.h (C / C++) and call DbiDllExit just before DbiExit. For Delphi, simply call DbiDllExit before DbiExit.


Q: "Insufficient memory to complete operation" error when attempting various BDE / Database operations: What is wrong?

A: More than likely, you have hit one of the BDE fixed, but configurable, memory limitations. Use the BDE Administrator (BDEADMIN.EXE) to increase MEMSIZE and SHAREDMEMSIZE settings. You might also want to re-evaluate the application hitting this limitation because it is likely that the application is a serious resource hit on the machine. Not using auto-create forms and only opening tables and queries when needed can free up resources.


Q: "Object not found" error with opening a STANDARD alias with a TDatabase: What is wrong?

A: Delphi 3.0 is attempting to get information on an alias parameter that does not exist on the STANDARD database alias you are trying to open. With the BDE Administrator (BDEADMIN.EXE), delete and re-create the alias.


Q: Sharing data dictionaries: How do I share data dictionaries?

A: The data dictionary is merely a table created in any database. To create, right click on the DB Explorer Dictionary tab, provide a unique dictionary name, select a database from the list to create the dictionary table in, provide a unique table name (you can leave BDESDD), and description is optional. Once the dictionary is created, you can see on the dictionary table exists on the Databases tab, under the database you specified. To share, the database and table specified in dictionary creation must exist in a shareable location, such as on an SQL server. At the second location, select from the Dictionary menu, Register. Provide any name for Dictionary name (using a company standard of some sort and everyone use the same name here is recommended), select the database table that contains the previously created dictionary table, table name, and description is once again optional. In cases where database tables are qualified with an owner name, the datadictionary table will also have this same feature/limitation. The same issue will be true for each table field being described -- i.e. if the field is myownerA.field1, table myownerb.field1 will not see the attributes described.


Q: "Your application is not enabled for use with this driver" error: What is the cause and how do I fix this error?

A: This error will be raised if an application created with Delphi Standard or Delphi Professional attempts to use any SQL Link driver (InterBase, Oracle, Informix, Sybase, MS-SQL). This error can also be raised if an application created with Delphi Standard attempts to use an ODBC driver. In order to create programs that use Borland's SQL Links, you must have Delphi Client / Server and to use ODBC, you must have at least Delphi Professional.


Q: "Invalid BLOb handle" error: What is the cause and how do I fix this error?

A: If the error occurs on a non-live (dead, canned) query or a table with no indexes, then increasing the new BDE4.0 configuration parameter 'BLOBS TO CACHE' will fix the problem. This setting determines how many BLObs will be cached on the client. Applications that deal with fetching dead BLObs using dead table opens or queries can set a limit on the number of BLObs to cache depending on the resource available on the client. Setting a value 100 means the application can work with a maximum of 100 BLOb records cached. Fetching more than 100, then scrolling back 100 records results in an "Invalid BLOb handle in record buffer" error message.
NOTE: This parameter does not apply to live table opens.

Default Value: 64
Range: 64 to 65536


Q: Informix SERIAL columns: Are they supported?

A: Yes. BDE 3.5/4.0 and the 3.5/4.0 Informix SQL Links driver will now automatically refresh an inserted row containing an Informix SERIAL column.


Q: ReportSmith with Delphi3: Can I open or create a project using the TReport ReportSmith component. Also, can I open an existing project from Delphi 2 in Delphi 3?

A: Yes. The TReport component is included in Delphi 3, but by default it is not included on the palette. If you wish to use the TReport component to create a new project you need to make it available for use on the palette. To do this choose Component | Configure Palette and move the TReport component from [Hidden] to a visible Palette (ie QReport).
NOTE: Delphi 3 does not ship with ReportSmith. You will need to install ReportSmith from your Delphi 2 CD.
NOTE: report.dcu and rsconsts.dcu are not in the search path by default. These files are located in "Delphi 3\Lib\Delphi2" directory and can either be moved to the "Delphi 3\Lib" directory or the path can be added to Delphi's search directory.


Q: BDE Administrator: "Object not found" error on startup: What does this error mean and how do I solve the problem?

A: This is a very ambiguous error that means an object (Database handle, Cusrsor handle, etc) could not be found that is vital to the BDE program startup. This only happens when ViewMode includes the virtual ODBC aliases. The solution in this case is to drop all the DSNs from the ODBC manager, upgrade to version 3.5 of the ODBC manager and add the DSNs back in again. The later step might not be necessary so try the upgrade first.


Q: Specifying a DefaultExpression for a TField object: How do I specify a DefaultExpression for a TField object?

A: If you set up a field attribute set and associate that set with a field in your table that will work. If you set the value in the object inspector it will let you enter in a string but it will not reflect the value at runtime. If you try to set the TField.DefaultExpression property at runtime like this:

MyField.DefaultExpression := 'MyValue';

It will compile but you will not get a default value at runtime when you create a new record in the table by, say, clicking on the + on the DBNavigator. To get the default value to take at runtime the code assignment needs to be:

MyField.DefaultExpression := '''MyValue''';

In the Object Inspector. You just need to put 'MyValue'. Use single quotes in the Object Inspector.


Q: Getting values in a TDBGrid before they are posted: How do I know what is being typed into the grid?

A: You can see what is being typed into a TDBGrid by looking at the TInPlaceEdit control of the TDBGrid. Care should be taken to make sure that the TInPlaceEdit control is created before trying to use it. The following function will show the data in the column of the grid that is being edited:

procedure TForm1.DBGrid1KeyUp(Sender: TObject; 
     var Key: Word; Shift: TShiftState);
var
  B: byte;

begin
  for B := 0 to DBGrid1.ControlCount - 1 do
  if DBGrid1.Controls[B] is TInPlaceEdit then
  begin
    with DBGrid1.Controls[B] as TInPlaceEdit do
    begin
      Label1.Caption := 'Text = ' + Text;
    end;
  end;
end;

Please reference TInPlaceEdit in the Delphi 3 help file for more information on it's functionality.


If one of the above topics need to be elaborated on, or you do not see a simple question about Delphi 3 that is not answered above, send a short message to the BDE Administrator

US developer support questions should be handled through any of the Borland Assist options. Non-US developer support should be handled through an international Borland office in your area. The administrator of this page reserves the right to reply only to questions pertaining to the current page. All other types of inquiries will be ignored! Back To Top

Delphi Q and A Trademarks & Copyright © 1997 Borland International, Inc.