[Qtscript-bindings] QtScript + QSqlQuery error

Seb Ruiz ruiz at kde.org
Tue Oct 7 03:52:57 CEST 2008


Hi there,
I've been struggling to use QSql from within QtScript, I would be appreciative
for any hints or tips as to solving this problem. FWIW, this all occurs within
Amarok.

Let me show you what I am doing:

Creating an SQLite database connection to a particular file.

      var db = QSqlDatabase.addDatabase( "QSQLITE", "sebr" );
      db.setDatabaseName( QDir.homePath() + "sebr.db" );
      db.open();

The database connection is well formed and the database is opened
correctly. I know this with certainty since I can pull data out of the
sqlite database reliably.

I want to execute a prepared statement using the database object that
I have created.

      var query = db.exec(); //Constructs a QSqlQuery object
      query.prepare( "SELECT id FROM urls WHERE rpath = :rpath" );

the query object is created properly and I have verified that it is
indeed of the QSqlQuery class. However, when trying to prepare the
statement, QtScript throws an exception.

      var url = QDir.homePath() + "test";
      query.bindValue( ":rpath", url, QSql.In );
      result = query.exec();


My error occurs at: query.bindValue( ":rpath", url, QSql.In );

      Script Error: "21:39:02 Error: QFile::bindValue(): could not find a
function match; candidates are:
      bindValue(String placeholder, Object val, ParamType type)
      bindValue(int pos, Object val, ParamType type) on Line: -1"

I really have no clue as to what is going wrong.

FYI: yes, I have already loaded the qt.core and qt.sql modules.

Many thanks
Seb

-- 
Seb Ruiz

http://www.sebruiz.net/
http://amarok.kde.org/


More information about the Qtscript-bindings mailing list