Technical Information Database TI203B.txt BDE Frequently Asked Questions. Category :General Programming Platform :All Product :BDE All Description: This document contains information most often provided to users of the BDE. FREQUENTLY ASKED QUESTIONS AND ANSWERS -------------------------------------- 1) General 2) Paradox Table Specifics 3) dBASE Table Specifics GENERAL ------- For additional information other than what is provided in this document, see: http://www.borland.com/devsupport/bde/faq/ Q: Is there any "Getting started" information on the BDE? A: Yes - get the TI177B for information on getting started with the BDE. Q: What basic steps can I follow to make my BDE application run smoothly? A: 1) Increase stack size to 20K. (16 bit only) 2) Increase the number of file handles available to your application using the Windows API function SetHandleCount. (16 bit only) 3) Check the return values of each and every BDE function call and provide some means for handling the result of any return value other than DBIERR_NONE. (See next question also). 4) Take a look at TI177B, which describes the basic steps that are required in setting up a BDE application. Q: I'm having trouble with my program, and the debugger has traced the problem into a BDE DLL. Does this mean that there is a bug in the BDE? A: Not necessarily. Frequently if a prior call to the BDE has failed due to being passed an invalid handle or for some other reason, this will leave the BDE in an unpredictable state which will later cause a GP fault. The solution is to check the return values of each and every function call you make. The BDE sample applications contain error handling routines. Q: Why is my application having problems when share is loaded? A: One possibility is that share could be running out of locks or file handles. The command line 'share /L:200 /F:4096' will increase the number of files that can be locked to 200 and the memory available for files to 4096 (the default is 20 and 2048). See your DOS or WINDOWS manual for more information on share. This information only applies to Windows 3.1. Windows for Workgroups, Windows 95 and Windows NT load share automatically. Windows 3.1 users can get this same functionality and not have to worry about running out of locks or file handles by obtaining the Windows 3.1 version of VSHARE.DLL from Microsoft. Q: Why am I getting the error "Cannot find NetWare.DLL"? A: An outdated netware.drv is found in the System.ini file. A newer version of this file should be gotten from your network administrator, and/or Novell. Q: How do I use the BDE in a DLL that is called from Paradox for Windows or dBASE for Windows? A: Make certain to use dynamic linking when using the BDE in a DLL called from another application. This will be done automatically when using the IDAPI.LIB that ships with the BDE, but will not be done if an import library was created using IMPLIB (the shipping IDAPI.LIB is more than a standard import library). Q: Why am I having problems getting information from the DbiGetFieldDescs function? A: Make certain to have 'Allocate Enums as Ints' set (Options | Compiler | Code Generation in BC 4.x, Options | Project | Compiler | Code Generation in BC 5.). The FLDDesc structure, which is used by DbiGetFieldDesc, contains an enum, which within the DLL is set to the same size as an int (two bytes). Q: Why am I having stack corruption problems? or Why is my application crashing when calling or returning from a function? A: First, make certain that you have 25k of stack allocated for your application. Then, make certain that you have 'Allocate enums as ints' selected. A number of structures, including CURProps, make use of enumerations. As there enumerations are allocated two bytes within the DLL, we need to make certain that the application is passing two bytes as well. This is done with the 'Allocate enums as ints' option. Q: How can I optimize BDE performance on table operations? A: Although there are a number of ways to improve BDE performance, some general things to try are as follows: 1) Keep the number of maintained secondary indexes to a minimum; sometimes it is better to delete the index and recreate it than to perform a number of table operations with the indexes in place. 2) If possible, increase the size of the swap buffer and the number of file handles that the BDE has available to it. This will decrease the Engine's need to swap resources. Note: make certain to increase the file handles available to your application using SetHandleCount, as well as increasing the number of file handles available to the BDE in IDAPI.CFG. 3) Open the table exclusively. 4) Batch as many opperations as possible - do not read/ write records one as a time. Use DbiBatchMove, DbiCopyTable, DbiReadBlock, and/or DbiWriteBlock. 5) When using DbiWriteBlock, try to work in multiples of the physical block size, usually 2k or 4k. 6) If you are opening and closing one or more tables repeatedly, consider calling DbiAcqPersistTableLock on a non-existent file after you initialize the BDE. This will create the .LCK file so that it will not have to be created each time a table is opened, created, etc. (Note: you'll also want to call DbiRelPersistTableLock before calling DbiExit). 7) Used Cached Updates Paradox Tables Only. 8) Work with in-memory tables when possible (Note that in-memory tables cannot be the source table to DbiBatchMove). Q: What are the current versions of the BDE? A: http://www.borland.com/devsupport/bde/bdever.html Q: Why am I getting the error 'Invalid BLOB Handle in record Buffer' when I attempt to modify a record containing a BLOB? A: This error can occur for two different reasons. Case 1 - BDE API Application This error is caused by not setting up the record correctly. Make certain to call DbiInitRecord on the record buffer before reading the record from the table. CASE 2 - Any BDE Application This error occurs when scrolling through more than 64 blobs in the results of a dead query. The solution is to either make the results of the query a live result set, or somehow limitscrolling blobs. (Such as having your SELECT statement select fewer records.) NOTE:A future release of the BDE is planned to be able to be configured to get past the present hard coded limit. Q: Why does my application crash when using filters? A: Beside the general suggestion at the top of this file, as well as errors in setting up offsets of the filter, this error can be caused by setting the iPriority parameter to DbiAddFiler to 0. Make certain to set this value to 1. (There is a misprint in some copies of the BDE Users Guide to set this to 0). Q: What's new in the 32 bit version? A: 1) Long filename support. 2) UNC filename support. 3) Transactions on Paradox and dBASE tables. 4) Cached Updates. 5) The method for preparing queries has changed, requiring the use of a new BDEfunction, DbiQAlloc, to obtain a statement handle. 6) BDE Configuration Information can now optionally be stored in the registry. 7) New SQL Engine. Q: Why am I getting the error "Too many open files" in the 16 bit version? A: You need to call SetHandleCount and make sure the value is larger than the MAXFILEHANDLES statement in BDECFG. Q. Can the BDE use descending indexes? A. Only the Paradox, dBASE and FoxPro drivers support descending indexes. Selecting a descending index for any other table type will make the data appear in ascending order. Q. With 16 bit BDE, how come I get a GPF in DBMSSOC3.DLL when connecting or disconnecting from my MSSQL database? A. This problem can occur when using TCP/IP as the transport. The BDE calls W3DBLIB.DLL, which in turn calls DBMSSOC3.DLL. The problem occurs most commonly when using Windows NT but can occur under Windows 3.1. It has not been reported against Windows 95. There are a number of potential solutions to this problems. 1. If the problem occurs under Windows NT, use 32 bit BDE instead. 2. Try switching providers of the TCP/IP stack. The testing for BDE 16 bit was done against Windows 3.1 using the Microsoft TCP/IP stack. 3. Use a different protocol. 4. Users have reported that replacing DBMSSOC.DLL with WDBWSKTC.DLL from the Sybase client resolves this problem. 5. For Windows 3.1 users, it has been reported you can connect using MicroSoft's 32 bit ODBC drivers, which would then use the 32 bit TCP/IP stack and solve the problem. PARADOX TABLE SPECIFICS ----------------- Q: How do I access tables in a read-only directory (such as a table on a CD-ROM)? A: A directory lock needs to be placed within the directory containing the table to prevent the BDE from attempting to create a lock file (.LCK) in that directory. An example of this is included in the SNIPIT example application, in the file RDOLOCK.C. Q: I got "Table locked/busy" and it's neither? A: This error happens when the application tries to lock a table when the corresponding prevent lock already exists, or when the application tries to set a prevent lock and a conflicting lock already exists. Check for old, unused lock files. Delete any .lck files that may exist after all BDE applications have terminated. Also run the TUtility program to test for table validity. Q: Why do I get the error "Multiple Paradox Net Files Found?" A: In addition to the case of two application referencing different physical PARADOX.NET files, this error message can be caused by old .LCK files or when two applications using the same NET file are mapped differently. Also make certain that the BDE DLL's are not left in memory. This error can also occur if differnt mapping are used to reference the same file. For example, if h:onetwo on one system points to the same physical location as h:three on another system, the BDE will not recognize that it is only a single .NET file. Make certain that the path matches. Q: I am working with a Peer-to-Peer network, like Windows for Workgroups, Lantastic, or Personal Netware, and I am getting "Multiple Paradox Net Files Found", what is wrong? A: The BDE requires that everyone use the exact same directory and drive letter. Therefore, if the tables are on c:tables on the shared drive and user maps the shared drive as f: then f:tables points to the same place as the shared drive's c:tables. However, the drive letter must also match. The way around this is to subst drive c: as drive f: This way both c: and f: point to the same drive. Now f:tables on the shared drive's computer points to the c:tables and everyone is using f:tables. For more information on the subst command look in your DOS manual. However, remember that if LASTDRIVE is set to f: in your CONFIG.SYS then the last drive you can subst is f: Q. I am getting the error "Lock file has grown too large". What is the solution? A. Download TI256B for a detailed answer. Q: Why am I getting the error: "Could not initialize IDAPI - not initialized for accessing network drives" when attempting to open a table on a network? A: 1) Make certain the network control directory (NET DIR) is set to a directory on the network (not local). This is set in the BDE Configuration utility. 2) Make certain that you have read/write/create rights to the network control directory, as well as the directory containing the table. 3) Make certain that the private directory is set to a local directory. For example, in the Database Desktop (DBD), the private directory is set in the WIN.INI file, in the [DBD] section, PrivDir. If it is set to a directory on the network, this error can occur. 4) Old lock files exist in the private directory. Either the application previously crashed, resulting in improper cleanup, or another application is using the same private directory. 5) Under Windows for Workgroups (WfW), search your hard drive for the NWCALLS.DLL. Rename/backup the older versions of this file and run again. If this fails to resolve the problem, you will need to make certain to not use the NetBEUI protocol as the default network protocol in Windows Setup. Select NetWare (or some other protocol) as the networking protocol, and everything should work successfully. dBASE TABLE SPECIFICS --------------- Q: How do I insert a Date into a dBASE table using Local SQL? A: 'INSERT INTO myTable (myField) value ("01/01/94")' Q: How can I create a case-insensitive index? A: Case insensitive indexes are not directly supported, but can be simulated using an expression index with the upper() function. Q: Why can I insert a duplicate record into a dBASE table when I have a unique index defined? A: dBASE does not enforce the uniqueness within the table - only within the index. When the table is opened on that index, only one record with a given key value will be present in the index, but both values exist in the table. Reference: 7/15/98 3:24:22 PM
Last Modified: 11-NOV-99