PDA

View Full Version : Database and QSqlQuery::prepare problem



fengtian.we
31st October 2007, 23:43
mycode:


void MainWindow::test()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("mytest");
db.setUserName("root");
db.setPassword("111111");

if (!db.open())
{
QMessageBox::information (this,"Database Error",db.lastError().text());
}
else
{
qDebug() << "Database OK";
}

QSqlQuery *query=new QSqlQuery(db);

query->prepare("insert into testtable(t_data1,t_data2) value(?,?)");
query->addBindValue(3);
query->addBindValue(55);
query->exec();

qDebug() << query->lastError().text();
}



output :
Database OK
"Using unsupported buffer type: -842150451 (parameter: 2) QMYSQL3: Unable to bind value"



database is not change. why???

jacek
1st November 2007, 00:17
What are the types of testtable fields?