Luc4
26th September 2010, 14:31
Hi! I created some tables using sqlite with Qt. My problem is that I noticed that using bindValue this way:
query.prepare("INSERT INTO monitored_files "
"VALUES (NULL, :fileName, :original_relative_dir_path, :backupped_relative_dir_path, :directory_id)");
query.bindValue(":fileName", entries.at(i));
query.bindValue(":original_relative_dir_path", processRelativeDirPath);
query.bindValue(":backupped_relative_dir_path", processRelativeDirPath);
query.bindValue(":directory_id", directoryId);
query.exec();
where entries.at(i) is P9040479.JPG and processRelativeDirPath is "." (without "s), I get this when listing the records in sqlite:
1|'P9040479.JPG'|'.'|'.'|1
this seems to be wrong as, if I write the query directly in sqlite:
insert into monitored_files values (null, 'P9040479.JPG', '.', '.', 1);
I get:
2|P9040479.JPG|.|.|1
The schema of my table is:
CREATE TABLE monitored_files (file_id INTEGER PRIMARY KEY,file_name VARCHAR(32767),original_relative_dir_path VARCHAR(32767),backupped_relative_dir_path VARCHAR(32767),directory_id INTEGER);
So it seems those Qt instructions are placing single quotes that shouldn't be there... My variables don't have those single quotes. Any idea where they come from?
Thanks!
query.prepare("INSERT INTO monitored_files "
"VALUES (NULL, :fileName, :original_relative_dir_path, :backupped_relative_dir_path, :directory_id)");
query.bindValue(":fileName", entries.at(i));
query.bindValue(":original_relative_dir_path", processRelativeDirPath);
query.bindValue(":backupped_relative_dir_path", processRelativeDirPath);
query.bindValue(":directory_id", directoryId);
query.exec();
where entries.at(i) is P9040479.JPG and processRelativeDirPath is "." (without "s), I get this when listing the records in sqlite:
1|'P9040479.JPG'|'.'|'.'|1
this seems to be wrong as, if I write the query directly in sqlite:
insert into monitored_files values (null, 'P9040479.JPG', '.', '.', 1);
I get:
2|P9040479.JPG|.|.|1
The schema of my table is:
CREATE TABLE monitored_files (file_id INTEGER PRIMARY KEY,file_name VARCHAR(32767),original_relative_dir_path VARCHAR(32767),backupped_relative_dir_path VARCHAR(32767),directory_id INTEGER);
So it seems those Qt instructions are placing single quotes that shouldn't be there... My variables don't have those single quotes. Any idea where they come from?
Thanks!