BUG: ESQL: AV Using Void * for Fost Variable for Binary DatatypeID: Q184559
|
BUG #: 17889 (SQLBUG_65)
37106 (SQLBUG_70)
When using "void *" to map a SQL BINARY column, an access violation (AV) may occur in Sqlakw32.dll.
To work around this problem, use the method described in the following
article in the Microsoft Knowledge Base:
Q184564 : INF: ESQL: How to Handle Binary Data in ESQL
Microsoft has confirmed this to be a problem in Microsoft Embedded SQL
for C Programmer's Toolkit version 6.5.
A supported fix is now available, but has not been fully regression-
tested and should be applied only to systems experiencing this specific
problem. Unless you are severely impacted by this specific problem,
Microsoft recommends that you wait for the next Service Pack that contains
this fix. Contact Microsoft Technical Support for more information.
The ESQL documentation states in one section that the SQL binary datatype
maps to the void * C datatype. However, using a void * for an input host
variable causes an access violation in Sqlakw32.dll.
The hotfix address two issues:
EXEC SQL BEGIN DECLARE SECTION;
void * pColBinary;
int iId = 0;
EXEC SQL END DECLARE SECTION;
.
.
.
pColBinary = malloc(10);
memcpy(pColBinary,"\x44\x49\x00\x00\x0c\x42\x42\x42\x42\x42",10);
EXEC SQL
SELECT Id INTO :iId
FROM tblBinary
WHERE ColBinary =[ASCII 160]:pColBinary;
if (SQLCODE != 0)
{
printf(" SQL Code = %li\n", SQLCODE);
printf(" SQL Server Message %li: '%Fs'\n", SQLERRD1,
SQLERRMC);
}
else
printf("The ID is = %d\n", iId);
.
.
.
free(pColBinary);
sqlasetv(2, 0, 444, -1, (void far *)&pColBinary, (void far *)0, (void far *)0L);
Additional query words: data type
Keywords : SSrvESQL_C SSrvProg kbbug6.50
Version : WINNT:6.5
Platform : winnt
Issue type : kbbug
Last Reviewed: April 20, 1999