注:文中例子均使用QSQLITE
一,增
QSqlQuery query;query.prepare(QString("INSERT INTO playList%1(songname,songurl,duration)"
"VALUES (:songname, :songurl,:duration)").arg(m_objIndex));
query.bindValue(":songname", songname);
query.bindValue(":songurl", url);
query.bindValue(":duration", dur);
query.exec();
二,删
QSqlQuery query;query.prepare(QString("DELETE FROM playlistname WHERE listname = ?"));
query.addBindValue(name);
query.exec();
三,改
query.prepare("update playlistname set listname = ? where listname = ?");
query.addBindValue(newname);
query.addBindValue(oldname);
query.exec();
四,查
QSqlQuery query1(QString("SELECT * FROM playList%1").arg(m_objIndex));
int fieldNo = query1.record().indexOf("songname");
while (query1.next()) {
QString name = query1.value(fieldNo).toString();
list1<<name;
}
mfc的
常用SQL语句 查询语句sql.Format("select * from xsxx where name='%s'",m_user1) 表示从 xsxx表中 选择 name=m_user1这一列 添加语句 sql.Format("insert into xsxx(name,sex,age,num) values('%s','%s','%s','%s')",m_user1,m_user2,m_user3,m_user4); 删除语句 sql.Format("delete from xsxx where name='%s'",m_user); 修改语句 sql.Format("update xsxx set num='%s',age='%s',sex='%s' where name='%s'",m_user4,m_user3,m_user2,m_user1);
powered by:小乌龟在大乌龟背上
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/25559.html