3
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /fasttmp/mkdist-qt-4.5.2-1245473805/qt-x11-opensource-src-4.5.2/src/sql/kernel/qsqlerror.cpp -->
7
<title>Qt 4.5: QSqlError Class Reference</title>
7
<title>Qt 4.6: QSqlError Class Reference</title>
8
8
<link href="classic.css" rel="stylesheet" type="text/css" />
11
<a name="//apple_ref/cpp/cl//QSqlError" />
11
12
<table border="0" cellpadding="0" cellspacing="0" width="100%">
13
<td align="left" valign="top" width="32"><a href="http://qtsoftware.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="namespaces.html"><font color="#004faf">All Namespaces</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
15
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QSqlError Class Reference<br /><span class="small-subtitle">[<a href="qtsql.html">QtSql</a> module]</span>
14
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
15
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
16
</tr></table><h1 class="title">QSqlError Class Reference<br /><span class="small-subtitle">[<a href="qtsql.html">QtSql</a> module]</span>
17
18
<p>The QSqlError class provides SQL database error information. <a href="#details">More...</a></p>
18
<pre> #include <QSqlError></pre><ul>
19
<pre> #include <QSqlError></pre><p><b>This class is not part of the Qt GUI Framework Edition.</b></p>
19
21
<li><a href="qsqlerror-members.html">List of all members, including inherited members</a></li>
21
24
<a name="public-types"></a>
24
<li><div class="fn"></div>enum <b><a href="qsqlerror.html#ErrorType-enum">ErrorType</a></b> { NoError, ConnectionError, StatementError, TransactionError, UnknownError }</li>
26
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
27
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#ErrorType-enum">ErrorType</a></b> { NoError, ConnectionError, StatementError, TransactionError, UnknownError }</td></tr>
26
30
<a name="public-functions"></a>
27
<h3>Public Functions</h3>
29
<li><div class="fn"></div><b><a href="qsqlerror.html#QSqlError">QSqlError</a></b> ( const QString & <i>driverText</i> = QString(), const QString & <i>databaseText</i> = QString(), ErrorType <i>type</i> = NoError, int <i>number</i> = -1 )</li>
30
<li><div class="fn"></div><b><a href="qsqlerror.html#QSqlError-2">QSqlError</a></b> ( const QSqlError & <i>other</i> )</li>
31
<li><div class="fn"></div><b><a href="qsqlerror.html#dtor.QSqlError">~QSqlError</a></b> ()</li>
32
<li><div class="fn"></div>QString <b><a href="qsqlerror.html#databaseText">databaseText</a></b> () const</li>
33
<li><div class="fn"></div>QString <b><a href="qsqlerror.html#driverText">driverText</a></b> () const</li>
34
<li><div class="fn"></div>bool <b><a href="qsqlerror.html#isValid">isValid</a></b> () const</li>
35
<li><div class="fn"></div>int <b><a href="qsqlerror.html#number">number</a></b> () const</li>
36
<li><div class="fn"></div>void <b><a href="qsqlerror.html#setDatabaseText">setDatabaseText</a></b> ( const QString & <i>databaseText</i> )</li>
37
<li><div class="fn"></div>void <b><a href="qsqlerror.html#setDriverText">setDriverText</a></b> ( const QString & <i>driverText</i> )</li>
38
<li><div class="fn"></div>void <b><a href="qsqlerror.html#setNumber">setNumber</a></b> ( int <i>number</i> )</li>
39
<li><div class="fn"></div>void <b><a href="qsqlerror.html#setType">setType</a></b> ( ErrorType <i>type</i> )</li>
40
<li><div class="fn"></div>QString <b><a href="qsqlerror.html#text">text</a></b> () const</li>
41
<li><div class="fn"></div>ErrorType <b><a href="qsqlerror.html#type">type</a></b> () const</li>
42
<li><div class="fn"></div>QSqlError & <b><a href="qsqlerror.html#operator-eq">operator=</a></b> ( const QSqlError & <i>other</i> )</li>
31
<h2>Public Functions</h2>
32
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
33
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#QSqlError">QSqlError</a></b> ( const QString & <i>driverText</i> = QString(), const QString & <i>databaseText</i> = QString(), ErrorType <i>type</i> = NoError, int <i>number</i> = -1 )</td></tr>
34
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#QSqlError-2">QSqlError</a></b> ( const QSqlError & <i>other</i> )</td></tr>
35
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#dtor.QSqlError">~QSqlError</a></b> ()</td></tr>
36
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#databaseText">databaseText</a></b> () const</td></tr>
37
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#driverText">driverText</a></b> () const</td></tr>
38
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#isValid">isValid</a></b> () const</td></tr>
39
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#number">number</a></b> () const</td></tr>
40
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#setDatabaseText">setDatabaseText</a></b> ( const QString & <i>databaseText</i> )</td></tr>
41
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#setDriverText">setDriverText</a></b> ( const QString & <i>driverText</i> )</td></tr>
42
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#setNumber">setNumber</a></b> ( int <i>number</i> )</td></tr>
43
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#setType">setType</a></b> ( ErrorType <i>type</i> )</td></tr>
44
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#text">text</a></b> () const</td></tr>
45
<tr><td class="memItemLeft" align="right" valign="top">ErrorType </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#type">type</a></b> () const</td></tr>
46
<tr><td class="memItemLeft" align="right" valign="top">QSqlError & </td><td class="memItemRight" valign="bottom"><b><a href="qsqlerror.html#operator-eq">operator=</a></b> ( const QSqlError & <i>other</i> )</td></tr>
44
48
<a name="details"></a>
46
50
<h2>Detailed Description</h2>
49
53
<p>See also <a href="qsqldatabase.html#lastError">QSqlDatabase::lastError</a>() and <a href="qsqlquery.html#lastError">QSqlQuery::lastError</a>().</p>
51
55
<h2>Member Type Documentation</h2>
56
<a name="//apple_ref/cpp/tag/QSqlError/ErrorType" />
57
<a name="//apple_ref/cpp/econst/QSqlError/NoError" />
58
<a name="//apple_ref/cpp/econst/QSqlError/ConnectionError" />
59
<a name="//apple_ref/cpp/econst/QSqlError/StatementError" />
60
<a name="//apple_ref/cpp/econst/QSqlError/TransactionError" />
61
<a name="//apple_ref/cpp/econst/QSqlError/UnknownError" />
62
<a name="//apple_ref/cpp/econst/QSqlError/None" />
63
<a name="//apple_ref/cpp/econst/QSqlError/Connection" />
64
<a name="//apple_ref/cpp/econst/QSqlError/Statement" />
65
<a name="//apple_ref/cpp/econst/QSqlError/Transaction" />
66
<a name="//apple_ref/cpp/econst/QSqlError/Unknown" />
52
67
<h3 class="fn"><a name="ErrorType-enum"></a>enum QSqlError::ErrorType</h3>
53
68
<p>This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.</p>
54
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
69
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
55
70
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
56
71
<tr><td valign="top"><tt>QSqlError::NoError</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">No error occurred.</td></tr>
57
72
<tr><td valign="top"><tt>QSqlError::ConnectionError</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Connection error.</td></tr>
63
78
<h2>Member Function Documentation</h2>
79
<a name="//apple_ref/cpp/instm/QSqlError/QSqlError" />
64
80
<h3 class="fn"><a name="QSqlError"></a>QSqlError::QSqlError ( const <a href="qstring.html">QString</a> & <i>driverText</i> = QString(), const <a href="qstring.html">QString</a> & <i>databaseText</i> = QString(), <a href="qsqlerror.html#ErrorType-enum">ErrorType</a> <i>type</i> = NoError, int <i>number</i> = -1 )</h3>
65
81
<p>Constructs an error containing the driver error text <i>driverText</i>, the database-specific error text <i>databaseText</i>, the type <i>type</i> and the optional error number <i>number</i>.</p>
66
82
<h3 class="fn"><a name="QSqlError-2"></a>QSqlError::QSqlError ( const QSqlError & <i>other</i> )</h3>
67
83
<p>Creates a copy of <i>other</i>.</p>
84
<a name="//apple_ref/cpp/instm/QSqlError/~QSqlError" />
68
85
<h3 class="fn"><a name="dtor.QSqlError"></a>QSqlError::~QSqlError ()</h3>
69
86
<p>Destroys the object and frees any allocated resources.</p>
87
<a name="//apple_ref/cpp/instm/QSqlError/databaseText" />
70
88
<h3 class="fn"><a name="databaseText"></a><a href="qstring.html">QString</a> QSqlError::databaseText () const</h3>
71
89
<p>Returns the text of the error as reported by the database. This may contain database-specific descriptions; it may be empty.</p>
72
90
<p>See also <a href="qsqlerror.html#setDatabaseText">setDatabaseText</a>(), <a href="qsqlerror.html#driverText">driverText</a>(), and <a href="qsqlerror.html#text">text</a>().</p>
91
<a name="//apple_ref/cpp/instm/QSqlError/driverText" />
73
92
<h3 class="fn"><a name="driverText"></a><a href="qstring.html">QString</a> QSqlError::driverText () const</h3>
74
93
<p>Returns the text of the error as reported by the driver. This may contain database-specific descriptions. It may also be empty.</p>
75
94
<p>See also <a href="qsqlerror.html#setDriverText">setDriverText</a>(), <a href="qsqlerror.html#databaseText">databaseText</a>(), and <a href="qsqlerror.html#text">text</a>().</p>
95
<a name="//apple_ref/cpp/instm/QSqlError/isValid" />
76
96
<h3 class="fn"><a name="isValid"></a>bool QSqlError::isValid () const</h3>
77
97
<p>Returns true if an error is set, otherwise false.</p>
81
101
if (model.lastError().isValid())
82
102
qDebug() << model.lastError();</pre>
83
103
<p>See also <a href="qsqlerror.html#type">type</a>().</p>
104
<a name="//apple_ref/cpp/instm/QSqlError/number" />
84
105
<h3 class="fn"><a name="number"></a>int QSqlError::number () const</h3>
85
106
<p>Returns the database-specific error number, or -1 if it cannot be determined.</p>
86
107
<p>See also <a href="qsqlerror.html#setNumber">setNumber</a>().</p>
108
<a name="//apple_ref/cpp/instm/QSqlError/setDatabaseText" />
87
109
<h3 class="fn"><a name="setDatabaseText"></a>void QSqlError::setDatabaseText ( const <a href="qstring.html">QString</a> & <i>databaseText</i> )</h3>
88
110
<p>Sets the database error text to the value of <i>databaseText</i>.</p>
89
111
<p>See also <a href="qsqlerror.html#databaseText">databaseText</a>(), <a href="qsqlerror.html#setDriverText">setDriverText</a>(), and <a href="qsqlerror.html#text">text</a>().</p>
112
<a name="//apple_ref/cpp/instm/QSqlError/setDriverText" />
90
113
<h3 class="fn"><a name="setDriverText"></a>void QSqlError::setDriverText ( const <a href="qstring.html">QString</a> & <i>driverText</i> )</h3>
91
114
<p>Sets the driver error text to the value of <i>driverText</i>.</p>
92
115
<p>See also <a href="qsqlerror.html#driverText">driverText</a>(), <a href="qsqlerror.html#setDatabaseText">setDatabaseText</a>(), and <a href="qsqlerror.html#text">text</a>().</p>
116
<a name="//apple_ref/cpp/instm/QSqlError/setNumber" />
93
117
<h3 class="fn"><a name="setNumber"></a>void QSqlError::setNumber ( int <i>number</i> )</h3>
94
118
<p>Sets the database-specific error number to <i>number</i>.</p>
95
119
<p>See also <a href="qsqlerror.html#number">number</a>().</p>
120
<a name="//apple_ref/cpp/instm/QSqlError/setType" />
96
121
<h3 class="fn"><a name="setType"></a>void QSqlError::setType ( <a href="qsqlerror.html#ErrorType-enum">ErrorType</a> <i>type</i> )</h3>
97
122
<p>Sets the error type to the value of <i>type</i>.</p>
98
123
<p>See also <a href="qsqlerror.html#type">type</a>().</p>
124
<a name="//apple_ref/cpp/instm/QSqlError/text" />
99
125
<h3 class="fn"><a name="text"></a><a href="qstring.html">QString</a> QSqlError::text () const</h3>
100
126
<p>This is a convenience function that returns <a href="qsqlerror.html#databaseText">databaseText</a>() and <a href="qsqlerror.html#driverText">driverText</a>() concatenated into a single string.</p>
101
127
<p>See also <a href="qsqlerror.html#driverText">driverText</a>() and <a href="qsqlerror.html#databaseText">databaseText</a>().</p>
128
<a name="//apple_ref/cpp/instm/QSqlError/type" />
102
129
<h3 class="fn"><a name="type"></a><a href="qsqlerror.html#ErrorType-enum">ErrorType</a> QSqlError::type () const</h3>
103
130
<p>Returns the error type, or -1 if the type cannot be determined.</p>
104
131
<p>See also <a href="qsqlerror.html#setType">setType</a>().</p>
132
<a name="//apple_ref/cpp/instm/QSqlError/operator=" />
105
133
<h3 class="fn"><a name="operator-eq"></a>QSqlError & QSqlError::operator= ( const QSqlError & <i>other</i> )</h3>
106
134
<p>Assigns the <i>other</i> error's values to this error.</p>
107
135
<p /><address><hr /><div align="center">
108
136
<table width="100%" cellspacing="0" border="0"><tr class="address">
109
<td width="30%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
110
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
111
<td width="30%" align="right"><div align="right">Qt 4.5.2</div></td>
112
</tr></table></div></address></body>
137
<td width="40%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
138
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
139
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
140
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>