Consultor Eletrônico



Kbase 15239: ODBC - Using Visual Basic with Arrayed Columns
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
ODBC - Using Visual Basic with Arrayed Columns

Using Visual Basic wit tables that contain arrayed columns will not
always work correctly. In fact, in certain cases the insertion will
cause a general protection fault. The following will cause the
insertion to fail:

Using VB with ODBC there are two methods to manipulate data. One is
using a data control with single fields, and the other is using
dynasets. Dynasets are dynamic sets of records that are used to add,
modify and delete rows of data from a database. Using dynasets you
only have to use a single statement to insert an entire record. A
dynaset (record set) is attached to a data control and all fields that
are associated with that data control become part of the dynaset.
Visual Basic creates the query dynamically and sorts fields in the
dynaset alphabetically. So if you had table foo with fields cust-num,
address, and city, the insert statement would appear as follows:
Insert into foo (address, city, cust-num) values (?,?,?).
The question marks indicate that all parameters are dynamic. Here's
where the problem comes in. VB apps that use dynasets, arrayed
columns and additional character fields that follow the arrayed
columns alphabetically, and do not force the user to enter data in all
fields will encounter problems.

VB interprets all character strings as varchars. As it defines each
parameter using the SQLBindParameter function, it passes an address
for that parameter (rgbValue) and a length (pcbValue). PcbValues are
only necessary with character string fields. NOTE: The pcbValue is
new for Version 2.0 of ODBC. Problems ONLY occur when not all the
arrayed fields, and character fields that alphabetically follow the
array are not filled in on the input form. If all fields are
mandatory, everything works fine.

Decimal arrayed fields that fall into the above category (e.g. they
use dynasets and not all the fields are filled in and character
fields alphabetically follow the arrayed fields) will fail and may
even gpf.

Integer arrayed field that meet the above criteria will succeed, but
the data for the empty array field immediately preceding the character
field will have the incorrect value. It's value will be set to the
length of the character string.

To avoid this problem using VB dynasets, make sure that all fields are
mandatory. This will ensure that all field values will be entered.

Progress Software Technical Support Note # 15239