QSqlQuery queryEx(QString q){Dialog dd;QSqlQuery sqlQuery,res; if (!sqlQuery.exec(q)){ dd.errorMessage("DB Error:"+ sqlQuery.lastError().text()); return FALSE; } else{ sqlQuery.exec(q); res=sqlQuery; sqlQuery.clear(); }return res;}void drop_coll(QString name){QSqlQuery tt=queryEx("SELECT * FROM addressbook");QSqlRecord rec=tt.record(); QString fields,rr=" "; queryEx("DROP TABLE IF EXISTS 'CustCopy'"); queryEx("CREATE TABLE IF NOT EXISTS 'CustCopy' (" "`id` INTEGER PRIMARY KEY NOT NULL," "`groop` INTEGER," "`name` char(200)," "`phone` char(200)" "); "); for(int j=0; j<rec.count(); j++) if( rec.fieldName(j)!=name) { if(j!=0) rr= ","; fields+=rr+" "+rec.fieldName(j)+" "; if(j>3) queryEx("ALTER TABLE 'CustCopy' ADD "+rec.fieldName(j) +" char(200)"); }queryEx("INSERT INTO CustCopy("+ fields + ") SELECT "+fields+" FROM addressbook");queryEx("DELETE FROM addressbook");queryEx("DROP TABLE addressbook");queryEx("ALTER TABLE CustCopy RENAME TO addressbook");}