📄 connection_connect.html
字号:
<html><head><meta name="KEYWORDS" content=" library, C++, Oracle, SQLServer, DB2, Sybase, Informix, InterBase, SQLBase, ODBC,
SQL, server, client, database, programming, development, software,
Win32, Windows, Linux, Unix, Solaris,
Microsoft, Borland, Centura, Gupta, IBM"><meta name="DESCRIPTION" content=
"SQLAPI++ is C++ library for accessing SQL databases (Oracle, SQLServer, Sybase, DB2, InterBase, SQLBase, Informix, ODBC).
It uses native APIs, provides low-level access to database-specific features."><title>SQLAPI++ Library - Online Documentation - SAConnection::Connect</title></head><body bgcolor="#ffffff" BACKGROUND="../images/bg.gif" text="#000000"><!--GlbHdr--> <table WIDTH="600" height="40" frame="hsides" BORDER="2" BORDERCOLOR="#004fcd" align="right" cellpadding="0" cellspacing="2" id="TABLE1">
<tr><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Home</b></font></A></td></TD>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../HowTo/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>How To</b></font></A></td><!--class="GlbActive"-->
<td width="70" bgcolor="#00bb00" bordercolor="black" align="middle"><A href="../OnLineDoc/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Online Documentation</b></font></A></td><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Support/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Support</b></font></A></td>
<td width=70 bgcolor=#000094 bordercolor=black align=middle>
<A href="../Download/index.html" style="TEXT-DECORATION: none" >
<font color=white size=3
face=sans-serif>
<b>Download</b></font></A></td>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Order/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Order</b></font></A></td> </tr>
</table>
<p> </p>
<p> </p>
<table width="100%">
<tr>
<td valign="top" width="165"><!--LeftMenu-->
<table frame="void" CELLSPACING="5" width="165">
<tr><td><p> </p></td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Command.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SACommand</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/red.gif" WIDTH="12" HEIGHT="12">
<A href="Connection.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAConnection</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Exception.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAException</font></A> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Field.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAField</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Param.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAParam</A> </FONT> </td>
</tr>
<tr><td><hr></td></tr>
<tr>
<td><img align=middle src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="String.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
SAString</A> </FONT> </td>
</tr>
<tr>
<td><img align=middle src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="DateTime.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
SADateTime</A> </FONT> </td>
</tr>
<tr>
<td><img align=middle src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Numeric.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
SANumeric</A> </FONT> </td>
</tr>
<tr><td><hr></td></tr>
<tr>
<td>
<A href="Enums.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
Enums and Typedefs</A> </FONT> </td>
</tr>
</table>
</td><!--empty column-->
<td width="20">
<p> </p>
</td><!--Content-->
<td valign="top" align="left">
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td align="left">
<A href="Connection_Usage.html" style="TEXT-DECORATION: none"><h3>Usage</h3></A>
</td>
<td align="left">
<A href="Connection.html" style="TEXT-DECORATION: none"><h3>Class Members</h3></A>
</td>
<td align="left">
<A href="Connection_Examples.html#Connect" style="TEXT-DECORATION: none"><h3>Examples</h3></A>
</td>
</tr>
<tr>
<td colspan="3"><h1>SAConnection::Connect</h1></td>
</tr>
</table>
<p><font face="Arial"><b> void Connect( const SAString &</b>sDBString<b> , const SAString &</b>sUserID<b> , const SAString &</b>sPassword<b> , SAClient_t</b>
eSAClient<b> =
SA_Client_NotSpecified );</b><b> <BR>throw (SAException);</b></font></p>
<p>
Opens the connection to a data
source.
</p>
<h3> Parameters</h3>
<P><EM>sDBString.</EM> Name of database this
connection will connect to (see <STRONG>Server specific
notes</STRONG>).</P>
<P><EM>sUserID.</EM> A string containing a user name to use
when establishing the connection (see <STRONG>Server specific
notes</STRONG>).</P>
<P><EM>sPassword.</EM> A string containing a
password to use when establishing the connection.</P>
<P><EM>eSAClient.</EM> Optional. One of the following values
from <STRONG>SAClient_t</STRONG> enum:</P>
<UL><STRONG>
<LI><STRONG>SA_Client_NotSpecified</STRONG></STRONG>
Used by default. Client is not specified.<STRONG>
<LI><STRONG>SA_Oracle_Client</STRONG></STRONG> Oracle
client.<STRONG>
<LI><STRONG>SA_SQLServer_Client</STRONG></STRONG> SQL
Server client.<STRONG>
<LI><STRONG>SA_InterBase_Client</STRONG></STRONG>
InterBase client.<STRONG>
<LI><STRONG>SA_SQLBase_Client</STRONG></STRONG>
SQLBase client.<STRONG>
<LI>SA_ODBC_Client</STRONG> ODBC client.
<LI><STRONG>SA_DB2_Client</STRONG> DB2 client.
<LI><STRONG>SA_Informix_Client</STRONG> Informix client.
<LI><STRONG>SA_Sybase_Client</STRONG> Sybase client.
<LI><STRONG>SA_MySQL_Client</STRONG> MySQL client.
<LI><STRONG>SA_PostgreSQL_Client</STRONG> PostgreSQL
client. </LI>
</UL>
<h3>Remarks</h3>
<p>
Using the <B>Connect</B>
method on a
<STRONG>SAConnection</STRONG>
object establishes the physical
connection to a data source. After this method successfully
completes, the connection is live and you can issue commands against
it and process the
results.
</p>
<p>
If you use the default value of
<EM>eSAClient</EM>
parameter, you should call <A
href="Connection_setClient.html">setClient</A>
method before using <STRONG>Connect</STRONG>.
</p>
<p>
To check whether a connection established use
<A
href="Connection_isConnected.html">isConnected</A>
method.
</p>
<h3>Server specific notes</h3>
<table width="100%" border=1 cellpadding=5>
<tr>
<td>
<p><STRONG><A
href="../ServerSpecific/Oracle.html" title="Oracle server specific information">Oracle</A></STRONG></p>
</td>
<td>
<p><EM>sDBString</EM> - the database name as it is
specified in TNSNAMES.ORA file.</p>
<p>If <EM>sUserID</EM> parameter is empty, SQLAPI++ Library
requests Oracle external authentication.</p>
<P>The SQLAPI++ Library requires
OCI version 7.3 or higher. The Library tries to connect
to Oracle using OCI8 first. If it fails it tries to
connect using OCI7.</P>
</td>
</tr>
<tr>
<td>
<p><STRONG><A
href="../ServerSpecific/SQLServer.html" title="SQL Server server specific information">SQL
Server</A>
</STRONG> </p>
</td>
<td>
<P><EM>sDBString</EM> - one of the
following formats:</P>
<UL>
<LI><STRONG>"" or
"@"</STRONG> - empty
string or '@' character, connects to a default
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -