MySQL Forums
Forum List  »  Connector/C++

problem using prepared statement
Posted by: imanol muñoz pandiella
Date: September 03, 2009 12:14PM

I want to make insert along prepared statements and i'm getting an error that i can understand... I use 2 functions to make the inserts. In the first i load on server the preparedstatement. This works perfect. In the second i fill the variables and i execute the query. Then when execute instruccion is being executed i get a sql exception.

The exception is this:

Using unsupported buffer type: 4544336 (parameter: 3) (MySQL error code: 2036, SQLState: HY000)

The field id have auto_increment activated. Prepared statement is a global variable called _pstmt. The code is this:

int ControladorDades::preparaInsertaServeis(){
try{
_pstmt = _con->prepareStatement((string)"INSERT INTO Serveis (id, numServei, dia, mes, any, hora, minut, idSoci, idTarifa) VALUES (NULL,?,?,?,?,?,?,?,?)");
} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
return -1*e.getErrorCode();
}
return 1;
}
int ControladorDades::insertaServei(int numServei, int dia, int mes, int any, int hora, int minut, int idSoci, int idTarifa){
try{
_pstmt->setInt(1,7);
_pstmt->setInt(2,7);
_pstmt->setInt(3,7);
_pstmt->setInt(4,7);
_pstmt->setInt(5,7);
_pstmt->setInt(6,7);
_pstmt->setInt(7,7);
_pstmt->setInt(8,7);
_pstmt->execute();
} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
return -1*e.getErrorCode();
}
return 1;
}

I tryed to load the prepared statement without (?) and it works perfect... i mean like this:
pstmt = _con->prepareStatement((string)"INSERT INTO Serveis (id, numServei, dia, mes, any, hora, minut, idSoci, idTarifa) VALUES (NULL,7,7,7,7,7,7,7,7)");

Investigating a bit i know that this error means:
Error: 2036 (CR_UNSUPPORTED_PARAM_TYPE)
Message: Using unsupported buffer type: %d (parameter: %d)

But i'm not english and i don't know what refers buffer type...

Please, help!

Imanol.

Options: ReplyQuote


Subject
Views
Written By
Posted
problem using prepared statement
3498
September 03, 2009 12:14PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.