AndyFutureRoute
Programmer
Morning....
I am having probs with a chunk of my code, its causing a segmentation fault when i try and execute an SQL command that i have bound paremeters too, I was wondering if anyone could pot an obvious mistake for me?!
for(unsigned int i = 0; i < rowNum.size(); i++){
SQLAllocHandle( SQL_HANDLE_STMT, hDbc ,&hStmt);
SQLPrepare(hStmt,(SQLCHAR*)"DELETE FROM [character] WHERE characterID = ?", SQL_NTS);
int val = rowNum;
cout << "Bind Vector Contents " << i << " "<< rowNum << " " ;
ret = SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_INTEGER, //ValueType INput
SQL_INTEGER, //ParameterType Actual Table Type
0, //ColumnSize
NULL, //DecimalDigits
&val, //ParameterValuePtr
sizeof(val), //BufferLength
SQL_NTS); //StrLen_or_IndPtr
SQLError(ret);
ret = SQLExecute(hStmt);
cout << "Delete OP "; SQLError(ret);
if(ret == SQL_SUCCESS){
norecordsinserted--;
}
SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
}
I am binding the value held in vector to the end of the delete statement, which should delete the appropriate record, i know that this vector hold the correct info, but when i execute the command it seg faults....
Any help?!?!?!.....
Cheers
Andy
I am having probs with a chunk of my code, its causing a segmentation fault when i try and execute an SQL command that i have bound paremeters too, I was wondering if anyone could pot an obvious mistake for me?!
for(unsigned int i = 0; i < rowNum.size(); i++){
SQLAllocHandle( SQL_HANDLE_STMT, hDbc ,&hStmt);
SQLPrepare(hStmt,(SQLCHAR*)"DELETE FROM [character] WHERE characterID = ?", SQL_NTS);
int val = rowNum;
cout << "Bind Vector Contents " << i << " "<< rowNum << " " ;
ret = SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_INTEGER, //ValueType INput
SQL_INTEGER, //ParameterType Actual Table Type
0, //ColumnSize
NULL, //DecimalDigits
&val, //ParameterValuePtr
sizeof(val), //BufferLength
SQL_NTS); //StrLen_or_IndPtr
SQLError(ret);
ret = SQLExecute(hStmt);
cout << "Delete OP "; SQLError(ret);
if(ret == SQL_SUCCESS){
norecordsinserted--;
}
SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
}
I am binding the value held in vector to the end of the delete statement, which should delete the appropriate record, i know that this vector hold the correct info, but when i execute the command it seg faults....
Any help?!?!?!.....
Cheers
Andy