SQLITE數據庫 

發表于:2013-04-22來源:Csdn作者:FreeBeer點擊數: 標簽:SQLServer
[cpp] view plaincopyprint? QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

  [cpp] view plaincopyprint?

  QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

  db.setDatabaseName("support");

  if(!db.open())

  {

  QMessageBox::critical(0, qApp->tr("Cannot open database"),

  qApp->tr("Unable to establish a database connection.\n"

  "This example needs SQLite support. Please read "

  "the Qt SQL driver documentation for information how "

  "to build it.\n\n"

  "Click Cancel to exit."), QMessageBox::Cancel);

  return false;

  }

  QSqlQuery q;

  q.exec("create table student(id integer primary key,name varchar,age integer)");

  q.exec("insert into student(id,name,age) values(1001,'AnPan',21)");

  q.exec("insert into student(id,name,age) values(1002,'CaoLL',22)");

  return true;

  QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

  db.setDatabaseName("support");

  if(!db.open())

  {

  QMessageBox::critical(0, qApp->tr("Cannot open database"),

  qApp->tr("Unable to establish a database connection.\n"

  "This example needs SQLite support. Please read "

  "the Qt SQL driver documentation for information how "

  "to build it.\n\n"

  "Click Cancel to exit."), QMessageBox::Cancel);

  return false;

  }

  QSqlQuery q;

  q.exec("create table student(id integer primary key,name varchar,age integer)");

  q.exec("insert into student(id,name,age) values(1001,'AnPan',21)");

  q.exec("insert into student(id,name,age) values(1002,'CaoLL',22)");

  return true;

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97