<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ibm-db2.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.db2-conn-error.php',
    1 => 'db2_conn_error',
    2 => 'Returns a string containing the SQLSTATE returned by the last connection attempt',
  ),
  'up' => 
  array (
    0 => 'ref.ibm-db2.php',
    1 => 'IBM DB2 Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.db2-commit.php',
    1 => 'db2_commit',
  ),
  'next' => 
  array (
    0 => 'function.db2-conn-errormsg.php',
    1 => 'db2_conn_errormsg',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ibm_db2/functions/db2-conn-error.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.db2-conn-error" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">db2_conn_error</h1>
  <p class="verinfo">(PECL ibm_db2 &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">db2_conn_error</span> &mdash; <span class="dc-title">
   Returns a string containing the SQLSTATE returned by the last connection attempt
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.db2-conn-error-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>db2_conn_error</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></span> <code class="parameter">$connection</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>



  <p class="simpara">
   <span class="function"><strong>db2_conn_error()</strong></span> returns an SQLSTATE value representing
   the reason the last attempt to connect to a database failed. As
   <span class="function"><a href="function.db2-connect.php" class="function">db2_connect()</a></span> returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in the event of a failed
   connection attempt, you do not pass any parameters to
   <span class="function"><strong>db2_conn_error()</strong></span> to retrieve the SQLSTATE value.
  </p>
  <p class="simpara">
   If, however, the connection was successful but becomes invalid over time,
   you can pass the <code class="parameter">connection</code> parameter to retrieve
   the SQLSTATE value for a specific connection.
  </p>
  <p class="para">
   To learn what the SQLSTATE value means, you can issue the following command
   at a DB2 Command Line Processor prompt:
   <strong class="userinput"><code>db2 &#039;? <code class="parameter">sqlstate-value</code>&#039;</code></strong>. You
   can also call <span class="function"><a href="function.db2-conn-errormsg.php" class="function">db2_conn_errormsg()</a></span> to retrieve an
   explicit error message and the associated SQLCODE value.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.db2-conn-error-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">connection</code></dt>
    <dd>
     <span class="simpara">
      A connection resource associated with a connection that initially
      succeeded, but which over time became invalid.
     </span>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.db2-conn-error-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   Returns the SQLSTATE value resulting from a failed connection attempt.
   Returns an empty string if there is no error associated with the last
   connection attempt.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.db2-conn-error-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 Retrieving an SQLSTATE value for a failed connection attempt</strong></p>
   <div class="example-contents"><p>
    The following example demonstrates how to return an SQLSTATE value
    after deliberately passing invalid parameters to
    <span class="function"><a href="function.db2-connect.php" class="function">db2_connect()</a></span>.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'badname'</span><span style="color: #007700">, </span><span style="color: #DD0000">'baduser'</span><span style="color: #007700">, </span><span style="color: #DD0000">'badpassword'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />    print </span><span style="color: #DD0000">"SQLSTATE value: " </span><span style="color: #007700">. </span><span style="color: #0000BB">db2_conn_error</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">SQLSTATE value: 08001</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.db2-conn-error-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.db2-conn-errormsg.php" class="function" rel="rdfs-seeAlso">db2_conn_errormsg()</a> - Returns the last connection error message and SQLCODE value</span></li>
   <li><span class="function"><a href="function.db2-connect.php" class="function" rel="rdfs-seeAlso">db2_connect()</a> - Returns a connection to a database</span></li>
   <li><span class="function"><a href="function.db2-stmt-error.php" class="function" rel="rdfs-seeAlso">db2_stmt_error()</a> - Returns a string containing the SQLSTATE returned by an SQL statement</span></li>
   <li><span class="function"><a href="function.db2-stmt-errormsg.php" class="function" rel="rdfs-seeAlso">db2_stmt_errormsg()</a> - Returns a string containing the last SQL statement error message</span></li>
  </ul>
 </div>



</div><?php manual_footer($setup); ?>