SQLBindCol & SQL_ATTR_ROW_ARRAY_SIZE

如果只设置 SQL_ATTR_ROW_ARRAY_SIZE > 1,而在绑定列的时候依然是SQL_ATTR_ROW_ARRAY_SIZE == 1时的缓存大小,在vc运行中将会导致一个HEAP_CORRUPT。在mingw中可能什么也不报,但是程序就停止在读数据的地方。

所以一定要在SQL_ATTR_ROW_ARRAY_SIZE > 1时,设置正确的缓冲区。

 

 

 70                 BindData projectname(100);
 71
 72                 size_t fetchSize = 3;
 73                 SQLSetStmtAttr(stmt.getHandle().getHandle(),
 74                         SQL_ATTR_ROW_ARRAY_SIZE,
 75                         (SQLPOINTER)fetchSize,
 76                         SQL_IS_UINTEGER);
 77
 78                 bindcol(stmt,meta.getColumnMetaData(0),id);
 79                 bindcol(stmt,meta.getColumnMetaData(1),areacode);
 80                 bindcol(stmt,meta.getColumnMetaData(2),category);
 81                 bindcol(stmt,meta.getColumnMetaData(3),projectname);
 82
 83                 while(cursor.fetchNext())
 84                         cout<< meta.getColumnMetaData(0).getColumnName()
 85                                 << "=" << id.m_mem.getValue<int>()
 86                                 << ","
 87                                 << meta.getColumnMetaData(1).getColumnName()

 88                                 << "=" << (char*)areacode.m_mem.getRawBlock(
    )
 89                                 << ","
@
11 lines yanked
                                                              73,3-17       56%

 

 

你可能感兴趣的:(array)