Results 1 to 1 of 1

Thread: SQLPrepare, SQLBind.... Probs Binding to DELETE Statement

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    Question SQLPrepare, SQLBind.... Probs Binding to DELETE Statement

    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[i];
    cout << "Bind Vector Contents " << i << " "<< rowNum[i] << " " ;
    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[i] 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
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width