Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ac91357d6caede925de099a02fced14e > files > 4637

qt4-doc-4.2.1-1.el5_7.1.x86_64.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/sql/kernel/qsqldatabase.cpp -->
<head>
  <title>Qt 4.2: QSqlDatabase Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QSqlDatabase Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1>
<p>The QSqlDatabase class represents a connection to a database. <a href="#details">More...</a></p>
<pre> #include &lt;QSqlDatabase&gt;</pre><ul>
<li><a href="qsqldatabase-members.html">List of all members, including inherited members</a></li>
<li><a href="qsqldatabase-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qsqldatabase.html#QSqlDatabase">QSqlDatabase</a></b> ()</li>
<li><div class="fn"/><b><a href="qsqldatabase.html#QSqlDatabase-2">QSqlDatabase</a></b> ( const QSqlDatabase &amp; <i>other</i> )</li>
<li><div class="fn"/><b><a href="qsqldatabase.html#dtor.QSqlDatabase">~QSqlDatabase</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#close">close</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#commit">commit</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#connectOptions">connectOptions</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#databaseName">databaseName</a></b> () const</li>
<li><div class="fn"/>QSqlDriver * <b><a href="qsqldatabase.html#driver">driver</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#driverName">driverName</a></b> () const</li>
<li><div class="fn"/>QSqlQuery <b><a href="qsqldatabase.html#exec">exec</a></b> ( const QString &amp; <i>query</i> = QString() ) const</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#hostName">hostName</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#isOpen">isOpen</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#isOpenError">isOpenError</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#isValid">isValid</a></b> () const</li>
<li><div class="fn"/>QSqlError <b><a href="qsqldatabase.html#lastError">lastError</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#open">open</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#open-2">open</a></b> ( const QString &amp; <i>user</i>, const QString &amp; <i>password</i> )</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#password">password</a></b> () const</li>
<li><div class="fn"/>int <b><a href="qsqldatabase.html#port">port</a></b> () const</li>
<li><div class="fn"/>QSqlIndex <b><a href="qsqldatabase.html#primaryIndex">primaryIndex</a></b> ( const QString &amp; <i>tablename</i> ) const</li>
<li><div class="fn"/>QSqlRecord <b><a href="qsqldatabase.html#record">record</a></b> ( const QString &amp; <i>tablename</i> ) const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#rollback">rollback</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a></b> ( const QString &amp; <i>options</i> = QString() )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setHostName">setHostName</a></b> ( const QString &amp; <i>host</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setPassword">setPassword</a></b> ( const QString &amp; <i>password</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setPort">setPort</a></b> ( int <i>port</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#setUserName">setUserName</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>QStringList <b><a href="qsqldatabase.html#tables">tables</a></b> ( QSql::TableType <i>type</i> = QSql::Tables ) const</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#transaction">transaction</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qsqldatabase.html#userName">userName</a></b> () const</li>
<li><div class="fn"/>QSqlDatabase &amp; <b><a href="qsqldatabase.html#operator-eq">operator=</a></b> ( const QSqlDatabase &amp; <i>other</i> )</li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>QSqlDatabase <b><a href="qsqldatabase.html#addDatabase">addDatabase</a></b> ( const QString &amp; <i>type</i>, const QString &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )</li>
<li><div class="fn"/>QSqlDatabase <b><a href="qsqldatabase.html#addDatabase-2">addDatabase</a></b> ( QSqlDriver * <i>driver</i>, const QString &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )</li>
<li><div class="fn"/>QSqlDatabase <b><a href="qsqldatabase.html#cloneDatabase">cloneDatabase</a></b> ( const QSqlDatabase &amp; <i>other</i>, const QString &amp; <i>connectionName</i> )</li>
<li><div class="fn"/>QStringList <b><a href="qsqldatabase.html#connectionNames">connectionNames</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#contains">contains</a></b> ( const QString &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )</li>
<li><div class="fn"/>QSqlDatabase <b><a href="qsqldatabase.html#database">database</a></b> ( const QString &amp; <i>connectionName</i> = QLatin1String( defaultConnection ), bool <i>open</i> = true )</li>
<li><div class="fn"/>QStringList <b><a href="qsqldatabase.html#drivers">drivers</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qsqldatabase.html#isDriverAvailable">isDriverAvailable</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#registerSqlDriver">registerSqlDriver</a></b> ( const QString &amp; <i>name</i>, QSqlDriverCreatorBase * <i>creator</i> )</li>
<li><div class="fn"/>void <b><a href="qsqldatabase.html#removeDatabase">removeDatabase</a></b> ( const QString &amp; <i>connectionName</i> )</li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qsqldatabase.html#QSqlDatabase-3">QSqlDatabase</a></b> ( const QString &amp; <i>type</i> )</li>
<li><div class="fn"/><b><a href="qsqldatabase.html#QSqlDatabase-4">QSqlDatabase</a></b> ( QSqlDriver * <i>driver</i> )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QSqlDatabase class represents a connection to a database.</p>
<p>The QSqlDatabase class provides an abstract interface for accessing database backends. It relies on database-specific <a href="qsqldriver.html">QSqlDriver</a>s to actually access and manipulate data.</p>
<p>The following code shows how to initialize a connection:</p>
<pre>     QSqlDatabase db = QSqlDatabase::addDatabase(&quot;QPSQL&quot;);
     db.setHostName(&quot;acidalia&quot;);
     db.setDatabaseName(&quot;customdb&quot;);
     db.setUserName(&quot;mojito&quot;);
     db.setPassword(&quot;J0a1m8&quot;);
     bool ok = db.open();</pre>
<p>Once a QSqlDatabase object has been created you can set the connection parameters with <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), <a href="qsqldatabase.html#setHostName">setHostName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), and <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>(). Once the parameters have been set up you can call <a href="qsqldatabase.html#open">open</a>() to open the connection.</p>
<p>The connection defined above is a nameless connection. If is the default connection and can be accessed using <a href="qsqldatabase.html#database">database</a>() later on:</p>
<pre>     QSqlDatabase db = QSqlDatabase::database();</pre>
<p>To make programming more convenient, QSqlDatabase is a value class. Any changes done to a database connection through one QSqlDatabase object will affect other QSqlDatabase objects representing the same connection. Call cloneConnection() if you want to create an independent database connection based on an existing one.</p>
<p>If you need multiple database connections simultaneously, specify an arbitrary name to <a href="qsqldatabase.html#addDatabase">addDatabase</a>() and <a href="qsqldatabase.html#database">database</a>(). Call <a href="qsqldatabase.html#removeDatabase">removeDatabase</a>() to remove connections. QSqlDatabase will output a warning if you try to remove a connection referenced by other QSqlDatabase objects. Use <a href="qsqldatabase.html#contains">contains</a>() to see if a given connection name is in the list of connections.</p>
<p>Once a connection is established you can see what tables the database offers with <a href="qsqldatabase.html#tables">tables</a>(), find the primary index for a table with <a href="qsqldatabase.html#primaryIndex">primaryIndex</a>(), get meta-information about a table's fields (e.g., their names) with <a href="qsqldatabase.html#record">record</a>(), and execute a query with <a href="qsqldatabase.html#exec">exec</a>().</p>
<p>If transactions are supported, you can use <a href="qsqldatabase.html#transaction">transaction</a>() to start a transaction, and then <a href="qsqldatabase.html#commit">commit</a>() or <a href="qsqldatabase.html#rollback">rollback</a>() to complete it. You can find out whether transactions are supported using <a href="qsqldriver.html#hasFeature">QSqlDriver::hasFeature</a>().</p>
<p>If an error occurred, it is given by <a href="qsqldatabase.html#lastError">lastError</a>().</p>
<p>The names of the underlying SQL drivers are available from <a href="qsqldatabase.html#drivers">drivers</a>(); you can check for a particular driver with <a href="qsqldatabase.html#isDriverAvailable">isDriverAvailable</a>(). If you have created your own custom driver, you can register it with <a href="qsqldatabase.html#registerSqlDriver">registerSqlDriver</a>().</p>
<p>See also <a href="qsqldriver.html">QSqlDriver</a>, <a href="qsqlquery.html">QSqlQuery</a>, and <a href="qtsql.html">QtSql Module</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QSqlDatabase"></a>QSqlDatabase::QSqlDatabase ()</h3>
<p>Creates an empty, invalid <a href="qsqldatabase.html">QSqlDatabase</a> object. Use <a href="qsqldatabase.html#addDatabase">addDatabase</a>(), <a href="qsqldatabase.html#removeDatabase">removeDatabase</a>(), and <a href="qsqldatabase.html#database">database</a>() to get valid <a href="qsqldatabase.html">QSqlDatabase</a> objects.</p>
<h3 class="fn"><a name="QSqlDatabase-2"></a>QSqlDatabase::QSqlDatabase ( const QSqlDatabase &amp; <i>other</i> )</h3>
<p>Creates a copy of <i>other</i>.</p>
<h3 class="fn"><a name="QSqlDatabase-3"></a>QSqlDatabase::QSqlDatabase ( const <a href="qstring.html">QString</a> &amp; <i>type</i> )&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>Creates a <a href="qsqldatabase.html">QSqlDatabase</a> connection that uses the driver referred to by <i>type</i>. If the <i>type</i> is not recognized, the database connection will have no functionality.</p>
<p>The currently available driver types are:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Driver Type</th><th>Description</th></tr></thead>
<tr valign="top" class="odd"><td>QDB2</td><td>IBM DB2</td></tr>
<tr valign="top" class="even"><td>QIBASE</td><td>Borland InterBase Driver</td></tr>
<tr valign="top" class="odd"><td>QMYSQL</td><td>MySQL Driver</td></tr>
<tr valign="top" class="even"><td>QOCI</td><td>Oracle Call Interface Driver</td></tr>
<tr valign="top" class="odd"><td>QODBC</td><td>ODBC Driver (includes Microsoft SQL Server)</td></tr>
<tr valign="top" class="even"><td>QPSQL</td><td>PostgreSQL Driver</td></tr>
<tr valign="top" class="odd"><td>QSQLITE</td><td><a href="3rdparty.html#sqlite">SQLite</a> version 3 or above</td></tr>
<tr valign="top" class="even"><td>QSQLITE2</td><td><a href="3rdparty.html#sqlite">SQLite</a> version 2</td></tr>
<tr valign="top" class="odd"><td>QTDS</td><td>Sybase Adaptive Server</td></tr>
</table></p>
<p>Additional third party drivers, including your own custom drivers, can be loaded dynamically.</p>
<p>See also <a href="sql-driver.html">SQL Database Drivers</a>, <a href="qsqldatabase.html#registerSqlDriver">registerSqlDriver</a>(), and <a href="qsqldatabase.html#drivers">drivers</a>().</p>
<h3 class="fn"><a name="QSqlDatabase-4"></a>QSqlDatabase::QSqlDatabase ( <a href="qsqldriver.html">QSqlDriver</a> * <i>driver</i> )&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>Creates a database connection using the given <i>driver</i>.</p>
<h3 class="fn"><a name="dtor.QSqlDatabase"></a>QSqlDatabase::~QSqlDatabase ()</h3>
<p>Destroys the object and frees any allocated resources.</p>
<p>If this is the last <a href="qsqldatabase.html">QSqlDatabase</a> object that uses a certain database connection, the is automatically closed.</p>
<p>See also <a href="qsqldatabase.html#close">close</a>().</p>
<h3 class="fn"><a name="addDatabase"></a>QSqlDatabase QSqlDatabase::addDatabase ( const <a href="qstring.html">QString</a> &amp; <i>type</i>, const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Adds a database to the list of database connections using the driver <i>type</i> and the connection name <i>connectionName</i>. If there already exists a database connection called <i>connectionName</i>, that connection is removed.</p>
<p>The database connection is referred to by <i>connectionName</i>. The newly added database connection is returned.</p>
<p>If <i>connectionName</i> is not specified, the newly added database connection becomes the default database connection for the application, and subsequent calls to <a href="qsqldatabase.html#database">database</a>() without a database name parameter will return a reference to it. If <i>connectionName</i> is given, use database(<i>connectionName</i>) to retrieve a pointer to the database connection.</p>
<p><b>Warning:</b> If you add a database with the same name as an existing database, the new database will replace the old one. This will happen automatically if you call this function more than once without specifying <i>connectionName</i>.</p>
<p>To make use of the connection, you will need to set it up, for example by calling some or all of <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), <a href="qsqldatabase.html#setHostName">setHostName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), and <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>(), and then you'll need to <a href="qsqldatabase.html#open">open</a>() the connection.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qsqldatabase.html#database">database</a>() and <a href="qsqldatabase.html#removeDatabase">removeDatabase</a>().</p>
<h3 class="fn"><a name="addDatabase-2"></a>QSqlDatabase QSqlDatabase::addDatabase ( <a href="qsqldriver.html">QSqlDriver</a> * <i>driver</i>, const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function is useful if you need to set up the database connection and instantiate the driver yourself. If you do this, it is recommended that you include the driver code in your own application. For example, setting up a custom PostgreSQL connection and instantiating the QPSQL driver can be done like this:</p>
<pre> #include &quot;qtdir/src/sql/drivers/psql/qsql_psql.cpp&quot;</pre>
<p>(We assume that <tt>qtdir</tt> is the directory where Qt is installed.) This will pull in the code that is needed to use the PostgreSQL client library and to instantiate a QPSQLDriver object, assuming that you have the PostgreSQL headers somewhere in your include search path.</p>
<pre> PGconn *con = PQconnectdb(&quot;host=server user=bart password=simpson dbname=springfield&quot;);
 QPSQLDriver *drv =  new QPSQLDriver(con);
 QSqlDatabase db = QSqlDatabase::addDatabase(drv); <span class="comment">// becomes the new default connection</span>
 QSqlQuery query;
 query.exec(&quot;SELECT NAME, ID FROM STAFF&quot;);
 ...</pre>
<p>The above code sets up a PostgreSQL connection and instantiates a QPSQLDriver object. Next, <a href="qsqldatabase.html#addDatabase">addDatabase</a>() is called to add the connection to the known connections so that it can be used by the Qt SQL classes. When a driver is instantiated with a connection handle (or set of handles), Qt assumes that you have already opened the database connection.</p>
<p>Remember that you must link your application against the database client library as well. The simplest way to do this is to add lines like the ones below to your <tt>.pro</tt> file:</p>
<pre> unix:LIBS += -lpq
 win32:LIBS += libpqdll.lib</pre>
<p>You will need to have the client library in your linker's search path.</p>
<p>The method described above will work for all the drivers, the only difference is the arguments the driver constructors take. Below is an overview of the drivers and their constructor arguments.</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Driver</th><th>Class name</th><th>Constructor arguments</th><th>File to include</th></tr></thead>
<tr valign="top" class="odd"><td>QPSQL</td><td>QPSQLDriver</td><td>PGconn *connection</td><td><tt>qsql_psql.cpp</tt></td></tr>
<tr valign="top" class="even"><td>QMYSQL</td><td>QMYSQLDriver</td><td>MYSQL *connection</td><td><tt>qsql_mysql.cpp</tt></td></tr>
<tr valign="top" class="odd"><td>QOCI</td><td>QOCIDriver</td><td>OCIEnv *environment, OCISvcCtx *serviceContext</td><td><tt>qsql_oci.cpp</tt></td></tr>
<tr valign="top" class="even"><td>QODBC</td><td>QODBCDriver</td><td>SQLHANDLE environment, SQLHANDLE connection</td><td><tt>qsql_odbc.cpp</tt></td></tr>
<tr valign="top" class="odd"><td>QDB2</td><td>QDB2</td><td>SQLHANDLE environment, SQLHANDLE connection</td><td><tt>qsql_db2.cpp</tt></td></tr>
<tr valign="top" class="even"><td>QTDS</td><td>QTDSDriver</td><td>LOGINREC *loginRecord, DBPROCESS *dbProcess, const <a href="qstring.html">QString</a> &amp;hostName</td><td><tt>qsql_tds.cpp</tt></td></tr>
<tr valign="top" class="odd"><td>QSQLITE</td><td>QSQLiteDriver</td><td>sqlite *connection</td><td><tt>qsql_sqlite.cpp</tt></td></tr>
<tr valign="top" class="even"><td>QIBASE</td><td>QIBaseDriver</td><td>isc_db_handle connection</td><td><tt>qsql_ibase.cpp</tt></td></tr>
</table></p>
<p>The host name (or service name) is needed when constructing the QTDSDriver for creating new connections for internal queries. This is to prevent the simultaneous usage of several <a href="qsqlquery.html">QSqlQuery</a>/<a href="porting4.html#qsqlcursor">QSqlCursor</a> objects from blocking each other.</p>
<p><b>Warning:</b> If you add a database with the same name as an existing database, the new database will replace the old one.</p>
<p><b>Warning:</b> The SQL framework takes ownership of the <i>driver</i> pointer, and it should not be deleted. If you want to explicitly remove the connection, use <a href="qsqldatabase.html#removeDatabase">removeDatabase</a>().</p>
<p>See also <a href="qsqldatabase.html#drivers">drivers</a>().</p>
<h3 class="fn"><a name="cloneDatabase"></a>QSqlDatabase QSqlDatabase::cloneDatabase ( const QSqlDatabase &amp; <i>other</i>, const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Clones the database connection <i>other</i> and and stores it as <i>connectionName</i>. All the settings from the original database, e.g. <a href="qsqldatabase.html#databaseName">databaseName</a>(), <a href="qsqldatabase.html#hostName">hostName</a>(), etc., are copied across. Does nothing if <i>other</i> is an invalid database. Returns the newly created database connection.</p>
<p>Note that the connection is not opened, to use it, it is neccessary to call <a href="qsqldatabase.html#open">open</a>() first.</p>
<h3 class="fn"><a name="close"></a>void QSqlDatabase::close ()</h3>
<p>Closes the database connection, freeing any resources acquired. This will also affect copies of this <a href="qsqldatabase.html">QSqlDatabase</a> object.</p>
<p>See also <a href="qsqldatabase.html#removeDatabase">removeDatabase</a>().</p>
<h3 class="fn"><a name="commit"></a>bool QSqlDatabase::commit ()</h3>
<p>Commits a transaction to the database if the driver supports transactions and a <a href="qsqldatabase.html#transaction">transaction</a>() has been started. Returns true if the operation succeeded; otherwise returns false.</p>
<p>Note that on some databases, this function will not work if there is an active <a href="qsqlquery.html">QSqlQuery</a> on the database. Use the <a href="qsqldatabase.html#lastError">lastError</a>() function to retrieve database-specific error data about the error that occurred.</p>
<p>See also <a href="qsqldriver.html#hasFeature">QSqlDriver::hasFeature</a>() and <a href="qsqldatabase.html#rollback">rollback</a>().</p>
<h3 class="fn"><a name="connectOptions"></a><a href="qstring.html">QString</a> QSqlDatabase::connectOptions () const</h3>
<p>Returns the connection options string used for this connection. The string may be empty.</p>
<p>See also <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>().</p>
<h3 class="fn"><a name="connectionNames"></a><a href="qstringlist.html">QStringList</a> QSqlDatabase::connectionNames ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a list containing the names of all connections.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qsqldatabase.html#contains">contains</a>() and <a href="qsqldatabase.html#database">database</a>().</p>
<h3 class="fn"><a name="contains"></a>bool QSqlDatabase::contains ( const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> = QLatin1String( defaultConnection ) )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns true if the list of database connections contains <i>connectionName</i>; otherwise returns false.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qsqldatabase.html#connectionNames">connectionNames</a>() and <a href="qsqldatabase.html#database">database</a>().</p>
<h3 class="fn"><a name="database"></a>QSqlDatabase QSqlDatabase::database ( const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> = QLatin1String( defaultConnection ), bool <i>open</i> = true )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the database connection called <i>connectionName</i>. The database connection must have been previously added with <a href="qsqldatabase.html#addDatabase">addDatabase</a>(). If <i>open</i> is true (the default) and the database connection is not already open it is opened now. If no <i>connectionName</i> is specified the default connection is used. If <i>connectionName</i> does not exist in the list of databases, an invalid connection is returned.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qsqldatabase.html#isOpen">isOpen</a>().</p>
<h3 class="fn"><a name="databaseName"></a><a href="qstring.html">QString</a> QSqlDatabase::databaseName () const</h3>
<p>Returns the connection's database name; it may be empty.</p>
<p>See also <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>().</p>
<h3 class="fn"><a name="driver"></a><a href="qsqldriver.html">QSqlDriver</a> * QSqlDatabase::driver () const</h3>
<p>Returns the database driver used to access the database connection.</p>
<p>See also <a href="qsqldatabase.html#addDatabase">addDatabase</a>() and <a href="qsqldatabase.html#drivers">drivers</a>().</p>
<h3 class="fn"><a name="driverName"></a><a href="qstring.html">QString</a> QSqlDatabase::driverName () const</h3>
<p>Returns the connection's driver name.</p>
<p>See also <a href="qsqldatabase.html#addDatabase">addDatabase</a>() and <a href="qsqldatabase.html#driver">driver</a>().</p>
<h3 class="fn"><a name="drivers"></a><a href="qstringlist.html">QStringList</a> QSqlDatabase::drivers ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a list of all the available database drivers.</p>
<p>See also <a href="qsqldatabase.html#registerSqlDriver">registerSqlDriver</a>().</p>
<h3 class="fn"><a name="exec"></a><a href="qsqlquery.html">QSqlQuery</a> QSqlDatabase::exec ( const <a href="qstring.html">QString</a> &amp; <i>query</i> = QString() ) const</h3>
<p>Executes a SQL statement on the database and returns a <a href="qsqlquery.html">QSqlQuery</a> object. Use <a href="qsqldatabase.html#lastError">lastError</a>() to retrieve error information. If <i>query</i> is empty, an empty, invalid query is returned and <a href="qsqldatabase.html#lastError">lastError</a>() is not affected.</p>
<p>See also <a href="qsqlquery.html">QSqlQuery</a> and <a href="qsqldatabase.html#lastError">lastError</a>().</p>
<h3 class="fn"><a name="hostName"></a><a href="qstring.html">QString</a> QSqlDatabase::hostName () const</h3>
<p>Returns the connection's host name. It may be empty.</p>
<p>See also <a href="qsqldatabase.html#setHostName">setHostName</a>().</p>
<h3 class="fn"><a name="isDriverAvailable"></a>bool QSqlDatabase::isDriverAvailable ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns true if a driver called <i>name</i> is available; otherwise returns false.</p>
<p>See also <a href="qsqldatabase.html#drivers">drivers</a>().</p>
<h3 class="fn"><a name="isOpen"></a>bool QSqlDatabase::isOpen () const</h3>
<p>Returns true if the database connection is currently open; otherwise returns false.</p>
<h3 class="fn"><a name="isOpenError"></a>bool QSqlDatabase::isOpenError () const</h3>
<p>Returns true if there was an error opening the database connection; otherwise returns false. Error information can be retrieved using the <a href="qsqldatabase.html#lastError">lastError</a>() function.</p>
<h3 class="fn"><a name="isValid"></a>bool QSqlDatabase::isValid () const</h3>
<p>Returns true if the <a href="qsqldatabase.html">QSqlDatabase</a> has a valid driver.</p>
<p>Example:</p>
<pre> QSqlDatabase db;
 qDebug() &lt;&lt; db.isValid();    <span class="comment">// Returns false</span>

 db = QSqlDatabase::database(&quot;sales&quot;);
 qDebug() &lt;&lt; db.isValid();    <span class="comment">// Returns true if &quot;sales&quot; connection exists</span>

 QSqlDatabase::removeDatabase(&quot;sales&quot;);
 qDebug() &lt;&lt; db.isValid();    <span class="comment">// Returns false</span></pre>
<h3 class="fn"><a name="lastError"></a><a href="qsqlerror.html">QSqlError</a> QSqlDatabase::lastError () const</h3>
<p>Returns information about the last error that occurred on the database.</p>
<p>Failures that occur in conjunction with an individual query are reported by <a href="qsqlquery.html#lastError">QSqlQuery::lastError</a>().</p>
<p>See also <a href="qsqlerror.html">QSqlError</a> and <a href="qsqlquery.html#lastError">QSqlQuery::lastError</a>().</p>
<h3 class="fn"><a name="open"></a>bool QSqlDatabase::open ()</h3>
<p>Opens the database connection using the current connection values. Returns true on success; otherwise returns false. Error information can be retrieved using <a href="qsqldatabase.html#lastError">lastError</a>().</p>
<p>See also <a href="qsqldatabase.html#lastError">lastError</a>(), <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), <a href="qsqldatabase.html#setHostName">setHostName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), and <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>().</p>
<h3 class="fn"><a name="open-2"></a>bool QSqlDatabase::open ( const <a href="qstring.html">QString</a> &amp; <i>user</i>, const <a href="qstring.html">QString</a> &amp; <i>password</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Opens the database connection using the given <i>user</i> name and <i>password</i>. Returns true on success; otherwise returns false. Error information can be retrieved using the <a href="qsqldatabase.html#lastError">lastError</a>() function.</p>
<p>This function does not store the password it is given. Instead, the password is passed directly to the driver for opening the connection and it is then discarded.</p>
<p>See also <a href="qsqldatabase.html#lastError">lastError</a>().</p>
<h3 class="fn"><a name="password"></a><a href="qstring.html">QString</a> QSqlDatabase::password () const</h3>
<p>Returns the connection's password. If the password was not set with <a href="qsqldatabase.html#setPassword">setPassword</a>(), and if the password was given in the <a href="qsqldatabase.html#open">open</a>() call, or if no password was used, an empty string is returned.</p>
<p>See also <a href="qsqldatabase.html#setPassword">setPassword</a>().</p>
<h3 class="fn"><a name="port"></a>int QSqlDatabase::port () const</h3>
<p>Returns the connection's port number. The value is undefined if the port number has not been set.</p>
<p>See also <a href="qsqldatabase.html#setPort">setPort</a>().</p>
<h3 class="fn"><a name="primaryIndex"></a><a href="qsqlindex.html">QSqlIndex</a> QSqlDatabase::primaryIndex ( const <a href="qstring.html">QString</a> &amp; <i>tablename</i> ) const</h3>
<p>Returns the primary index for table <i>tablename</i>. If no primary index exists an empty <a href="qsqlindex.html">QSqlIndex</a> is returned.</p>
<p>See also <a href="qsqldatabase.html#tables">tables</a>() and <a href="qsqldatabase.html#record">record</a>().</p>
<h3 class="fn"><a name="record"></a><a href="qsqlrecord.html">QSqlRecord</a> QSqlDatabase::record ( const <a href="qstring.html">QString</a> &amp; <i>tablename</i> ) const</h3>
<p>Returns a <a href="qsqlrecord.html">QSqlRecord</a> populated with the names of all the fields in the table (or view) called <i>tablename</i>. The order in which the fields appear in the record is undefined. If no such table (or view) exists, an empty record is returned.</p>
<h3 class="fn"><a name="registerSqlDriver"></a>void QSqlDatabase::registerSqlDriver ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, <a href="qsqldrivercreatorbase.html">QSqlDriverCreatorBase</a> * <i>creator</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This function registers a new SQL driver called <i>name</i>, within the SQL framework. This is useful if you have a custom SQL driver and don't want to compile it as a plugin.</p>
<p>Example:</p>
<pre> QSqlDatabase::registerSqlDriver(&quot;MYDRIVER&quot;,
                                 new QSqlDriverCreator&lt;MyDatabaseDriver&gt;);
 QSqlDatabase db = QSqlDatabase::addDatabase(&quot;MYDRIVER&quot;);</pre>
<p><a href="qsqldatabase.html">QSqlDatabase</a> takes ownership of the <i>creator</i> pointer, so you mustn't delete it yourself.</p>
<p>See also <a href="qsqldatabase.html#drivers">drivers</a>().</p>
<h3 class="fn"><a name="removeDatabase"></a>void QSqlDatabase::removeDatabase ( const <a href="qstring.html">QString</a> &amp; <i>connectionName</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Removes the database connection <i>connectionName</i> from the list of database connections.</p>
<p><b>Warning:</b> There should be no open queries on the database connection when this function is called, otherwise a resource leak will occur.</p>
<p>Example:</p>
<pre><span class="comment"> // WRONG</span>
 QSqlDatabase db = QSqlDatabase::database(&quot;sales&quot;);
 QSqlQuery query(&quot;SELECT NAME, DOB FROM EMPLOYEES&quot;, db);
 QSqlDatabase::removeDatabase(&quot;sales&quot;); <span class="comment">// will output a warning</span>

<span class="comment"> // &quot;db&quot; is now a dangling invalid database connection,</span>
<span class="comment"> // &quot;query&quot; contains an invalid result set</span></pre>
<p>The correct way to do it:</p>
<pre> {
     QSqlDatabase db = QSqlDatabase::database(&quot;sales&quot;);
     QSqlQuery query(&quot;SELECT NAME, DOB FROM EMPLOYEES&quot;, db);
 }
<span class="comment"> // Both &quot;db&quot; and &quot;query&quot; are destroyed because they are out of scope</span>
 QSqlDatabase::removeDatabase(&quot;sales&quot;); <span class="comment">// correct</span></pre>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qsqldatabase.html#database">database</a>().</p>
<h3 class="fn"><a name="rollback"></a>bool QSqlDatabase::rollback ()</h3>
<p>Rolls a transaction back on the database if the driver supports transactions and a <a href="qsqldatabase.html#transaction">transaction</a>() has been started. Returns true if the operation succeeded; otherwise returns false.</p>
<p>See also <a href="qsqldriver.html#hasFeature">QSqlDriver::hasFeature</a>() and <a href="qsqldatabase.html#commit">commit</a>().</p>
<h3 class="fn"><a name="setConnectOptions"></a>void QSqlDatabase::setConnectOptions ( const <a href="qstring.html">QString</a> &amp; <i>options</i> = QString() )</h3>
<p>Sets database-specific <i>options</i>. This must be done before the connection is opened or it has no effect (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again).</p>
<p>The format of the <i>options</i> string is a semicolon separated list of option names or option=value pairs. The options depend on the database client used:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>ODBC</th><th>MySQL</th><th>PostgreSQL</th></tr></thead>
<tr valign="top" class="odd"><td><ul>
<li>SQL_ATTR_ACCESS_MODE</li>
<li>SQL_ATTR_LOGIN_TIMEOUT</li>
<li>SQL_ATTR_CONNECTION_TIMEOUT</li>
<li>SQL_ATTR_CURRENT_CATALOG</li>
<li>SQL_ATTR_METADATA_ID</li>
<li>SQL_ATTR_PACKET_SIZE</li>
<li>SQL_ATTR_TRACEFILE</li>
<li>SQL_ATTR_TRACE</li>
<li>SQL_ATTR_CONNECTION_POOLING</li>
</ul>
</td><td><ul>
<li>CLIENT_COMPRESS</li>
<li>CLIENT_FOUND_ROWS</li>
<li>CLIENT_IGNORE_SPACE</li>
<li>CLIENT_SSL</li>
<li>CLIENT_ODBC</li>
<li>CLIENT_NO_SCHEMA</li>
<li>CLIENT_INTERACTIVE</li>
<li>UNIX_SOCKET</li>
</ul>
</td><td><ul>
<li>connect_timeout</li>
<li>options</li>
<li>tty</li>
<li>requiressl</li>
<li>service</li>
</ul>
</td></tr>
<thead><tr valign="top" class="qt-style"><th>DB2</th><th>OCI</th><th>TDS</th></tr></thead>
<tr valign="top" class="even"><td><ul>
<li>SQL_ATTR_ACCESS_MODE</li>
<li>SQL_ATTR_LOGIN_TIMEOUT</li>
</ul>
</td><td><ul>
<li>OCI_ATTR_PREFETCH_ROWS</li>
<li>OCI_ATTR_PREFETCH_MEMORY</li>
</ul>
</td><td><i>none</i></td></tr>
<thead><tr valign="top" class="qt-style"><th><a href="3rdparty.html#sqlite">SQLite</a></th></tr></thead>
<tr valign="top" class="odd"><td><ul>
<li>QSQLITE_BUSY_TIMEOUT</li>
</ul>
</td></tr>
</table></p>
<p>Examples:</p>
<pre> ...
<span class="comment"> // MySQL connection</span>
 db.setConnectOptions(&quot;CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1&quot;); <span class="comment">// use an SSL connection to the server</span>
 if (!db.open()) {
     db.setConnectOptions(); <span class="comment">// clears the connect option string</span>
     ...
 }
 ...
<span class="comment"> // PostgreSQL connection</span>
 db.setConnectOptions(&quot;requiressl=1&quot;); <span class="comment">// enable PostgreSQL SSL connections</span>
 if (!db.open()) {
     db.setConnectOptions(); <span class="comment">// clear options</span>
     ...
 }
 ...
<span class="comment"> // ODBC connection</span>
 db.setConnectOptions(&quot;SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY;SQL_ATTR_TRACE=SQL_OPT_TRACE_ON&quot;); <span class="comment">// set ODBC options</span>
 if (!db.open()) {
     db.setConnectOptions(); <span class="comment">// don't try to set this option</span>
     ...
 }</pre>
<p>Refer to the client library documentation for more information about the different options.</p>
<p>See also <a href="qsqldatabase.html#connectOptions">connectOptions</a>().</p>
<h3 class="fn"><a name="setDatabaseName"></a>void QSqlDatabase::setDatabaseName ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Sets the connection's name to <i>name</i>. This must be done before the connection is opened or it has no effect; (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again). The name is database-specific.</p>
<p>For the QOCI (Oracle) driver, the database name is the TNS Service Name.</p>
<p>For the QODBC driver, the <i>name</i> can either be a DSN, a DSN filename (in which case the file must have a <tt>.dsn</tt> extension), or a connection string.</p>
<p>For example, Microsoft Access users can use the following connection string to open an <tt>.mdb</tt> file directly, instead of having to create a DSN entry in the ODBC manager:</p>
<pre> ...
 db = QSqlDatabase::addDatabase(&quot;QODBC&quot;);
 db.setDatabaseName(&quot;DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=myaccessfile.mdb&quot;);
 if (db.open()) {
     <span class="comment">// success!</span>
 }
 ...</pre>
<p>There is no default value.</p>
<p>See also <a href="qsqldatabase.html#databaseName">databaseName</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), <a href="qsqldatabase.html#setHostName">setHostName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>(), and <a href="qsqldatabase.html#open">open</a>().</p>
<h3 class="fn"><a name="setHostName"></a>void QSqlDatabase::setHostName ( const <a href="qstring.html">QString</a> &amp; <i>host</i> )</h3>
<p>Sets the connection's host name to <i>host</i>. This must be done before the connection is opened or it has no effect (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again).</p>
<p>There is no default value.</p>
<p>See also <a href="qsqldatabase.html#hostName">hostName</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>(), and <a href="qsqldatabase.html#open">open</a>().</p>
<h3 class="fn"><a name="setPassword"></a>void QSqlDatabase::setPassword ( const <a href="qstring.html">QString</a> &amp; <i>password</i> )</h3>
<p>Sets the connection's password to <i>password</i>. This must be done before the connection is opened or it has no effect (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again).</p>
<p>There is no default value.</p>
<p><b>Warning:</b> This function stores the password in plain text within Qt. Use the <a href="qsqldatabase.html#open">open</a>() call that takes a password as parameter to avoid this behavior.</p>
<p>See also <a href="qsqldatabase.html#password">password</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setHostName">setHostName</a>(), <a href="qsqldatabase.html#setPort">setPort</a>(), <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>(), and <a href="qsqldatabase.html#open">open</a>().</p>
<h3 class="fn"><a name="setPort"></a>void QSqlDatabase::setPort ( int <i>port</i> )</h3>
<p>Sets the connection's port number to <i>port</i>. This must be done before the connection is opened or it has no effect (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again).</p>
<p>There is no default value.</p>
<p><a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>() <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>() <a href="qsqldatabase.html#open">open</a>()</p>
<p>See also <a href="qsqldatabase.html#port">port</a>(), <a href="qsqldatabase.html#setUserName">setUserName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), and <a href="qsqldatabase.html#setHostName">setHostName</a>().</p>
<h3 class="fn"><a name="setUserName"></a>void QSqlDatabase::setUserName ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Sets the connection's user name to <i>name</i>. This must be done before the connection is opened or it has no effect (or you can <a href="qsqldatabase.html#close">close</a>() the connection, call this function and <a href="qsqldatabase.html#open">open</a>() the connection again).</p>
<p>There is no default value.</p>
<p><a href="qsqldatabase.html#setPort">setPort</a>() <a href="qsqldatabase.html#setConnectOptions">setConnectOptions</a>() <a href="qsqldatabase.html#open">open</a>()</p>
<p>See also <a href="qsqldatabase.html#userName">userName</a>(), <a href="qsqldatabase.html#setDatabaseName">setDatabaseName</a>(), <a href="qsqldatabase.html#setPassword">setPassword</a>(), and <a href="qsqldatabase.html#setHostName">setHostName</a>().</p>
<h3 class="fn"><a name="tables"></a><a href="qstringlist.html">QStringList</a> QSqlDatabase::tables ( <a href="qsql.html#TableType-enum">QSql::TableType</a> <i>type</i> = QSql::Tables ) const</h3>
<p>Returns a list of the database's tables, system tables and views, as specified by the parameter <i>type</i>.</p>
<p>See also <a href="qsqldatabase.html#primaryIndex">primaryIndex</a>() and <a href="qsqldatabase.html#record">record</a>().</p>
<h3 class="fn"><a name="transaction"></a>bool QSqlDatabase::transaction ()</h3>
<p>Begins a transaction on the database if the driver supports transactions. Returns true if the operation succeeded; otherwise returns false.</p>
<p>See also <a href="qsqldriver.html#hasFeature">QSqlDriver::hasFeature</a>(), <a href="qsqldatabase.html#commit">commit</a>(), and <a href="qsqldatabase.html#rollback">rollback</a>().</p>
<h3 class="fn"><a name="userName"></a><a href="qstring.html">QString</a> QSqlDatabase::userName () const</h3>
<p>Returns the connection's user name; it may be empty.</p>
<p>See also <a href="qsqldatabase.html#setUserName">setUserName</a>().</p>
<h3 class="fn"><a name="operator-eq"></a>QSqlDatabase &amp; QSqlDatabase::operator= ( const QSqlDatabase &amp; <i>other</i> )</h3>
<p>Assigns <i>other</i> to this object.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="record-2"></a><a href="qsqlrecord.html">QSqlRecord</a> QSqlDatabase::record ( const <a href="qsqlquery.html">QSqlQuery</a> &amp; <i>query</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Use query.<a href="qsqldatabase.html#record">record</a>() instead.</p>
<h3 class="fn"><a name="recordInfo"></a><a href="qsqlrecord.html">QSqlRecord</a> QSqlDatabase::recordInfo ( const <a href="qstring.html">QString</a> &amp; <i>tablename</i> ) const</h3>
<p>Use <a href="qsqldatabase.html#record">record</a>() instead.</p>
<h3 class="fn"><a name="recordInfo-2"></a><a href="qsqlrecord.html">QSqlRecord</a> QSqlDatabase::recordInfo ( const <a href="qsqlquery.html">QSqlQuery</a> &amp; <i>query</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Use query.<a href="qsqldatabase.html#record">record</a>() instead.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>