You can use the database build in functions if your strings aren't too long. MySQL e.g supports
q.prepare("...SET name = SUBSTRING(:str,0,:len)...");
for(int i =0; i < sizeof(i_fieldlength)/sizeof(i_fieldlength[0]);++i)
{
q.bindValue(":str", splitlinelist.at(i));
q.bindValue(":len", i_fieldlength[i]);
q.exec();
}
q.prepare("...SET name = SUBSTRING(:str,0,:len)...");
for(int i =0; i < sizeof(i_fieldlength)/sizeof(i_fieldlength[0]);++i)
{
q.bindValue(":str", splitlinelist.at(i));
q.bindValue(":len", i_fieldlength[i]);
q.exec();
}
To copy to clipboard, switch view to plain text mode
NOTE: sizeof(i_fieldlength)/sizeof(i_fieldlength[0]) and ++i!
EDIT: splitlinelist.at(i) => at() is constant so you can't assign a value to that. If you want to use the [] operator.
Bookmarks