错误一:duplicate connetion name 'qt_sql_default_connection',old connection removed
解决办法:程序中多次建立了Qt与MySQL之间的连接,删除其中多于的建立关系,只保留一组即可。
错误二:QSqlQuery::value:not positioned on a valid record
解决办法:定义了QSqlQuery对象query后,query并没有指向任何记录,必须手动指定。可以使用next()、first()等。
但是注意一点,必须先执行query.exec(),在执行query.first()等语句,顺序很重要。