⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbconnection.htm

📁 The goal of this library is to make ODBC recordsets look just like an STL container. As a user, you
💻 HTM
字号:
<html>

 

<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
  -- Copyright 2000
  -- Michael Gradman & Corwin Joy
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Corwin Joy & Michael Gradman make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  --
  -- Copyright (c) 1996-1999
  -- Silicon Graphics Computer Systems, Inc.
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Silicon Graphics makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -- Copyright (c) 1994
  -- Hewlett-Packard Company
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Hewlett-Packard Company makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -->
<!-- Generated by htmldoc -->
<title>DBConnection</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">

<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>

<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p>
<h1>DBConnection</h1>

 


















<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td><img src="utilities.gif" width="194" height="38"></td>
        <td align="right"><img src="type.gif" width="194"
        height="39"></td>
    </tr>
    <tr>
        <td valign="top"><b>Category</b>: utilities</td>
        <td align="right" valign="top"><b>Component type</b>:
        type</td>
    </tr>
</table>
<h3>Description</h3>

<p>The <font size="2" face="Courier New">DBConnection </font>class
provides a mechanism to manage ODBC connections to a database.</p>

<h3>Definition</h3>

<p>Defined in the <font size="2" face="Courier New">DBConnection.h
</font>header file.</p>

<h3>Refinement of</h3>

<p>None.</p>

<h3>Associated types</h3>

<p>None.</p>

<h3>Example: Connecting to a database</h3>

<pre><code>int main(int argc, char **argv)
{
  DBConnection::GetDefaultConnection().Connect(&quot;UID=example;PWD=example;DSN=example;&quot;);

}
</pre></code>

<h3><font size="4">Public Base Classes</font></h3>

<p><a href="ValidatedObject.htm"><font size="2"
face="Courier New">ValidatedObject</font></a></p>

<h3>Notation</h3>

<table border="0">
    <tr>
        <td valign="top"><tt>X</tt> </td>
        <td valign="top">A type that is a model of DBConnection </td>
    </tr>
    <tr>
        <td valign="top"><tt>a</tt> </td>
        <td valign="top">Object of type <tt>X</tt> </td>
    </tr>
</table>

<h3>Expression semantics</h3>

<table border="1">
    <tr>
        <th>Name </th>
        <th>Expression </th>
        <th>Precondition </th>
        <th>Semantics </th>
        <th>Postcondition </th>
    </tr>
    <tr>
        <td valign="top">Constructor </td>
        <td valign="top"><pre>X a()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Creates an empty database connection
        object. The connection object cannot be used until it has
        been intialized with a <font size="2" face="Courier New">Connect()</font>
        call</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Connection Constructor </td>
        <td valign="top"><pre>Connect(string &amp;s)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Creates a database connection using the
        ODBC connect string contained in <font size="2"
        face="Courier New">s</font></td>
        <td valign="top">valid database connection - throw if
        error encountered</td>
    </tr>
    <tr>
        <td valign="top">Get the default connection object</td>
        <td valign="top"><pre>GetDefaultConnection()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Get the default connection object.
        Returns a static member of the <font size="2"
        face="Courier New">DBConnection</font> class used to hold
        the default connection object for the library. This
        default connection object is used as the default
        connection object by <a href="DBStmt.htm"><font size="2"
        face="Courier New">DBStmt</font></a>, <a
        href="DBView.htm"><font size="2" face="Courier New">DBView</font></a>
        and<font size="2" face="Courier New"> </font><a
        href="IndexedDBView.htm"><font size="2"
        face="Courier New">IndexedDBView</font></a> if no
        explicit connection parameter is specified in their
        constructors.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Commit all outstanding transactions</td>
        <td valign="top"><pre>CommitAll()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Commit all outstanding transactions
        against the database.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Commit all outstanding transactions</td>
        <td valign="top"><pre>RollbackAll()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Rollback all outstanding transactions
        against the database.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Get the raw ODBC HENV handle for the
        connection</td>
        <td valign="top"><pre>HENV GetHENV()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Returns the raw ODBC HENV handle.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Get the raw ODBC HDBC handle for the
        connection</td>
        <td valign="top"><pre>HDBC GetHDBC()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Returns the raw ODBC HDBC handle.</td>
        <td valign="top">&nbsp;</td>
    </tr>
   <tr>
        <td valign="top">Get the DSN string used by the connection.</td>
        <td valign="top"><pre>string GetDSN()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Returns the raw ODBC DSN string used by the connection.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Swap with another connection</td>
        <td valign="top"><pre>void swap(DBConnection &amp;other)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Swap <font size="2" face="Courier New">*this</font>
        with <font size="2" face="Courier New">other</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
</table>

<h3>Notes</h3>

<h3>See also</h3>

<p><a href="DBStmt.htm"><font size="2" face="Courier New">DBStmt</font></a><font
size="2" face="Courier New">, </font><a href="DBView.htm"><font
size="2" face="Courier New">DBView</font></a><font size="2"
face="Courier New">, </font><a href="IndexedDBView.htm"><font
size="2" face="Courier New">IndexedDBView</font></a><font
size="2" face="Courier New">, </font><a
href="ValidatedObject.htm"><font size="2" face="Courier New">ValidatedObject</font></a><a
href="IndexedDBView.htm"><font size="2"><!--start footer--></font></a></p>

<p>
<hr>

<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>

<p>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -