Friday, August 1, 2008

FAQs – July 2008

Here is the latest installment of my monthly FAQs. I got some very interesting questions during July and here are a few of the questions I received.

Using the DBC Convert utility

With the release of Advantage 9.0 we added support for the Visual FoxPro 9 table format. However, we do not support opening of Database Containers (DBC), so we created a utility to convert a DBC into an Advantage Data Dictionary (ADD). The utility is a FoxPro program (.prg file) which ships with the Advantage ODBC Driver and OLEDB Provider.

To use the utility you need to connect to your DBC from within FoxPro 9 and then run the dbcconvert.prg file. This will read the properties of the DBC and create an ADD which can be used by Advantage. This is a one time operation and does not track changes made to the DBC. If you change the DBC you will need to run the convert utility again or manually apply the same changes to your ADD.

The utility adds references to all the DBF files, creates long file names, converts table and field validation rules, default field values and referential integrity rules. If you are interested in using Advantage with your FoxPro application visit our Getting Started with FoxPro page.

Accessing Tables >4GB on Novell Netware

Advantage Database Server has supported ADT Tables >4GB in size since version 6.X and DBF Tables >4GB since version 8. This functionality is available “out of the box” for the Windows and Linux versions of the server. However, if you need to access files >4GB in size on a Netware machine you will need to contact sales and get a special build of the server. 

Connection Pooling

If you use the Advantage .NET Data Provider you may have some familiarity with Connection Pooling. By default the provider uses connection pooling to provide efficient use of resources. Since ADO.NET works with data in a disconnected fashion connections may get opened and closed frequently. The connection pool reduces the overhead of re-creating the connections over and over.

You can control the connection pool using the following key words in your connection string. The default values are in parenthesis “()”

  • Pooling – True or False (true)
  • Min Pool Size – integer value (0)
  • Max Pool Size – integer value (100)
  • Connection Lifetime – integer (0)

One potential problem with the connection pool is the chance that some connections will remain open longer than you want them to. It can take some time for the .NET garbage collector to completely close all of the connections in the pool. If you need to quickly close connections in the pool you can use the FlushConnectionPool() method. This ensures that all connections in the connection pool are closed. You can also specify a specific connection string which will close all connections using that string.

AdsConnection vs DatabaseName

When using the Advantage TDataset Descendent the TAdsTable and TAdsQuery components have two properties which can be used to specify the connection to use. AdsConnection is the preferred choice since it uses a pointer to the connection object. DatabaseName is a string and a bit more flexible since you can specify an alias, the name of the connection component or a path.

Additionally the AdsConnection property is a better choice when using a mulit-threaded application since passing the pointer is more reliable then depending on the name resolution logic which is used when the DatabaseName property is specified.

No comments: