我試圖運行下面的代碼:當進入情況SQL_CHAR並得到打破它跳SQLBindcol調用之前區分SQL_TYPE_DATE,怎麼可能,在C++開關故障如何?
SQLSMALLINT** column_types = new SQLSMALLINT*[*ColumnCount];
void** ColumnsData = new void*[*ColumnCount];
SQLINTEGER** rowLengths = new SQLINTEGER*[*ColumnCount];
int limit = *ColumnCount;
for(int i=0;i<limit;i++)
{
column_types[i] = new SQLSMALLINT();
SQLColAttribute(hStmt,i+1,SQL_DESC_TYPE,NULL,NULL,NULL,(SQLPOINTER)column_types[i]);
SQLSMALLINT type = *column_types[i];
switch(type)
{
case SQL_CHAR:
ColumnsData[i] = new SQLCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLCHAR**)ColumnsData[i])[l] = new SQLCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_CHAR,ColumnsData[i],512,rowLengths[i]);
break; //<<<<<<<<<<<<<<<<<<<<<<<<<<<
case SQL_VARCHAR:
ColumnsData[i] = new SQLCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLCHAR**)ColumnsData[i])[l] = new SQLCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_VARCHAR,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_LONGVARCHAR:
ColumnsData[i] = new SQLCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLCHAR**)ColumnsData[i])[l] = new SQLCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_LONGVARCHAR,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_WCHAR:
ColumnsData[i] = new SQLWCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLWCHAR**)ColumnsData[i])[l] = new SQLWCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_WCHAR,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_WVARCHAR:
ColumnsData[i] = new SQLWCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLWCHAR**)ColumnsData[i])[l] = new SQLWCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_WVARCHAR,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_WLONGVARCHAR:
ColumnsData[i] = new SQLWCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLWCHAR**)ColumnsData[i])[l] = new SQLWCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_WLONGVARCHAR,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_DECIMAL:
ColumnsData[i] = new SQL_NUMERIC_STRUCT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_DECIMAL,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_NUMERIC:
ColumnsData[i] = new SQL_NUMERIC_STRUCT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_NUMERIC,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_SMALLINT:
ColumnsData[i] = new SQLSMALLINT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_SMALLINT,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_INTEGER:
ColumnsData[i] = new SQLINTEGER[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_INTEGER,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_REAL:
ColumnsData[i] = new SQLREAL[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_REAL,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_FLOAT:
ColumnsData[i] = new SQLREAL[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_FLOAT,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_DOUBLE:
ColumnsData[i] = new SQLDOUBLE[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_DOUBLE,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_BIT:
ColumnsData[i] = new SQLCHAR[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_BIT,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_TINYINT:
ColumnsData[i] = new SQLSCHAR[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_TINYINT,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_BIGINT:
ColumnsData[i] = new SQLBIGINT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_BIGINT,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_BINARY:
ColumnsData[i] = new SQLCHAR**[*RowCount];
for(int l=0;l<*RowCount;l++)
{
((SQLCHAR**)ColumnsData[i])[l] = new SQLCHAR[512];
}
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_BINARY,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_TYPE_DATE:
ColumnsData[i] = new SQL_DATE_STRUCT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
//>>>>>>>>>>>>>>>
SQLBindCol(hStmt,i+1,SQL_TYPE_DATE,ColumnsData[i],512,rowLengths[i]);
break;
case SQL_TYPE_TIME:
ColumnsData[i] = new SQL_TIME_STRUCT[*RowCount];
rowLengths[i] = new SQLINTEGER[*RowCount];
SQLBindCol(hStmt,i+1,SQL_TYPE_TIME,ColumnsData[i],512,rowLengths[i]);
break;
default:
break;
}
}
是故障還是我我在這裏做錯了,因爲中斷應該退出交換機
在實際代碼中檢查一個額外的'}'。 – Barmar