[Qt-interest] can you help me spot where the error is?
Cimpean Andrei Sebastian
andreiamenta at gmail.com
Wed Sep 2 17:32:20 CEST 2009
hello everybody. i have a problem and wasn't able to fix it.
This below is my code... every time i run it it gives me this errors:
Eroarea este: " Parameter count mismatch"
Eroarea este: " Parameter count mismatch"
Eroarea este: " Parameter count mismatch"
Eroarea este: " Parameter count mismatch"
void database::insertElement(QList<QPair<QHash<int,QString>, int > > items)
{
/*
m_query->exec("SELECT * FROM indexedWithoutHash");
QSqlRecord record = m_query->record();
while(m_query->next()){
qDebug()<<m_query->value(record.indexOf("id")).toInt();
qDebug() <<m_query->numRowsAffected();
}
*/
for (int i=0;i<items.size();i++)
{
m_query->prepare("INSERT INTO indexedWithoutHash(filename, extension,
size, lastModified, parentPath, isDir, subDir, the_force)"
"VALUES(:filename,:extension,:size,:lastModified,:parentPath,:isDir,:subDir,:the_force)");
m_query->bindValue(":filename",items[i].first[0]);//filename
m_query->bindValue(":extension",items[i].first[1]);//extension
m_query->bindValue(":size",items[i].second);//size qint stuff bagamias pula
m_query->bindValue(":lastModified",items[i].first[2]);//last time modified
m_query->bindValue(":parentPath",items[i].first[3]);//parent filepath
m_query->bindValue(":isDir",items[i].first[4]);//is dir?
m_query->bindValue(":subDir",items[i].first[5]);//last time modified
if(i==0) m_query->bindValue(":the_force",1);
else m_query->bindValue(":the_force",0);
bool ok = m_query->exec();
if(!ok) {
m_error = m_query->lastError();
qDebug() <<"\nEroarea este: "<< m_error.text();
}
}
}
i am sending inside as a test some things and this is the function that
gives me those things:
QList<QPair<QHash<int,QString>, int > > fileHandler::findFiles(QString path)
{
QList<QPair<QHash<int,QString>, int > > lista;//list with hashes
QHash<int,QString> individuals;//this hash will hold each file selected
QDirIterator it(path,
QDir::AllEntries|QDir::NoDotAndDotDot,QDirIterator::FollowSymlinks);
while (it.hasNext()) {
individuals.insert(0,it.fileInfo().baseName());//filename without extension
individuals.insert(1,it.fileInfo().completeSuffix());//extension - only one
individuals.insert(2,it.fileInfo().lastModified().toString());//last
modified - converted from QDate to String
individuals.insert(3,it.fileInfo().path());//parent filepath
if(it.fileInfo().isDir())
{
individuals.insert(4,QString("folder"));//checks if folder
individuals.insert(5,it.fileInfo().absoluteFilePath());//filepath+name
of file, without suffix
}
QPair<QHash<int,QString>,int> r;
r.first = individuals;
r.second = it.fileInfo().size();
lista.append(r);
individuals.clear();//the hash has to be cleared so it does not stack
all the files in one big item
it.next();
}
return lista;
}
this function works great, but when i try to insert things into the
database i cannot. the funny thing is i was able to put some test data
inside the database.
my fields look like this:
q = "CREATE TABLE indexedWithoutHash(";
q += " id INTEGER PRIMARY KEY AUTOINCREMENT, ";
q += " filename TEXT, ";
q += " extension TEXT, ";
q += " size TEXT, ";
q += " lastModified TEXT, ";
q += " parentPath TEXT, ";
q += " isDir INTEGER, ";
q += " subDirTEXT";
//q += " fileAttributes TEXT, ";
//q += " metaData TEXT, ";
q += " the_force INTEGER ";
q += " ); ";
ok = m_query->exec(q);
if(!ok){
m_error = m_query->lastError();
qDebug()<<m_error.text();
}
Thanks in advance.
More information about the Qt-interest-old
mailing list