Detailed Description
The QSqlRecord class encapsulates a database record.
The QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). QSqlRecord supports adding and removing fields as well as setting and retrieving field values.
The values of a record's fields' can be set by name or position with setValue(); if you want to set a field to null use setNull(). To find the position of a field by name use indexOf(), and to find the name of a field at a particular position use fieldName(). Use field() to retrieve a QSqlField object for a given field. Use contains() to see if the record contains a particular field name.
When queries are generated to be executed on the database only those fields for which isGenerated() is true are included in the generated SQL.
A record can have fields added with append() or insert(), replaced with replace(), and removed with remove(). All the fields can be removed with clear(). The number of fields is given by count(); all their values can be cleared (to null) using clearValues().
See also QSqlField and QSqlQuery::record().
The QSqlRecord 这个类封装了数据库的记录,这个类封装了数据记录的函数性和字符串的数据库(通常是在数据库中的一行和一个表或者是一个视图),QSqlRecord支持增加或者移除域只要尽说, 这个记录域的值可以设置通过用setValue(),假如你想要设置field为空,
bool QSqlQuery::exec ( const QString & query )
Executes the SQL in query. Returns true and sets the query state to active if the query was successful; otherwise returns false. Thequery string must use syntax appropriate for the SQL database being queried (for example, standard SQL).
After the query is executed, the query is positioned on an invalid record and must be navigated to a valid record before data values can be retrieved (for example, using next()).
Note that the last error for this query is reset when exec() is called.
Example:
QSqlQuery query;
query.exec("INSERT INTO employee (id, name, salary) "
"VALUES (1001, 'Thad Beaumont', 65000)");
See also isActive(), isValid(), next(), previous(), first(), last(), and seek().
执行字符串query,返回true改变查询状态,在查询以后查询指在一个无效的计记录并且必须操作一个有效的数据值可以收到用
The QSqlDatabase class represents a connection to a database.
The QSqlDatabase class provides an interface for accessing a database through a connection. An instance of QSqlDatabase represents the connection. The connection provides access to the database via one of the supported database drivers, which are derived from QSqlDriver. Alternatively, you can subclass your own database driver from QSqlDriver. See How to Write Your Own Database Driver for more information.
Create a connection (i.e., an instance of QSqlDatabase) by calling one of the static addDatabase() functions, where you specify the driver or type of driver to use (i.e., what kind of database will you access?) and a connection name. A connection is known by its own name, not by the name of the database it connects to. You can have multiple connections to one database. QSqlDatabase also supports the concept of a default connection, which is the unnamed connection. To create the default connection, don't pass the connection name argument when you call addDatabase(). Subsequently, when you call any static member function that takes the connection name argument, if you don't pass the connection name argument, the default connection is assumed. The following snippet shows how to create and open a default connection to a PostgreSQL database:
这个类代表了一个连接到数据库,它提供了一个访问数据库的接口通过一个连接。
创造一个连接,一个连接
这个重载函数当你想要一个创造一个连接用一个