📄 odbc_dsn.html
字号:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ActiveX Data Objects Tutorial</title>
<link rel="stylesheet" href="tutorial.css">
</head>
<body>
<h1>MySQL ODBC Data Sources and ADO Connection Strings</h1>
<p>Figure 1. Shows a MySQL ODBC 3.51 DSN Configuration Dialog which, as its name
suggests is used to configure user DSNs for MySQL. This visually shows the
various information needed in constructing a DSN and their corresponding places
and format in our sample connection string. TAKE NOTE that this connection
APPLIES ONLY to MySQL ODBC DSNs and may NOT BE APPLICABLE to other database
drivers or sources. Of course it would be better if we could use OLE DB by
directly connecting to the database without going through ODBC. Although
this would be the best alternative, it always depends upon the driver in use and
unfortunately, the OLE DB driver for MySQL sucks. (Pardon my French.)</p>
<p><img border="0" src="images/oledb-odbc.jpg" width="535" height="580"></p>
<p>Figure 1. Contrast using OLE DB to access ODBC sources and using OLE DB
directly</p>
<ol>
<li>Data Source Name (DSN)
<pre><font color="#FF0000">DSN=pcs</font>;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;UID=pcs;PASSWORD=cygnus;PORT=3306;OPTION=35;STMT=</pre></li>
<li>Description (DESC)<pre>DSN=pcs;<font color="#FF0000">DESC=MySQL ODBC 3.51 Driver DSN</font>;DATABASE=pcs;SERVER=localhost;UID=pcs;PASSWORD=cygnus;PORT=3306;OPTION=35;STMT=</pre></li>
<li>Host/Server Name (SERVER)<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;<font color="#FF0000">SERVER=localhost</font>;UID=pcs;PASSWORD=cygnus;PORT=3306;OPTION=35;STMT=</pre></li>
<li>Database (DATABASE)<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;<font color="#FF0000">DATABASE=pcs</font>;SERVER=localhost;UID=pcs;PASSWORD=cygnus;PORT=3306;OPTION=35;STMT=</pre>
<p>
<img border="0" src="images/ODBC.jpg" width="612" height="388"><br>
Figure 2. MySQL ODBC DSN Configuration Dialog<br>
</p></li>
<li>User (UID)*<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;<font color="#FF0000">UID=pcs</font>;PASSWORD=cygnus;PORT=3306;OPTION=35;STMT=</pre></li>
<li>Password (PASSWORD)*<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;UID=pcs;<font color="#FF0000">PASSWORD=cygnus</font>;PORT=3306;OPTION=35;STMT=</pre></li>
<li>Port (PORT)<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;UID=pcs;PASSWORD=cygnus;<font color="#FF0000">PORT=3306</font>;OPTION=35;STMT=</pre></li>
<li>SQL command on connect (STMNT)<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;UID=pcs;PASSWORD=cygnus;PORT=3306;OPTION=35;<font color="#FF0000">STMT=</font></pre></li>
</ol>
<p>* Take note that these can be excluded in the connection string but still
specified in the <a href="ado.html#Open()">Open()</a> function of the Connection
object.</p>
<h2>Options</h2>
<p><img border="0" src="images/ODBC-OPTIONS.jpg" width="510" height="365"><br>
<br>
Figure 1. MySQL ODBC Options</p>
<pre>DSN=pcs;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=pcs;SERVER=localhost;UID=pcs;PASSWORD=cygnus;PORT=3306;<font color="#FF0000">OPTION=35</font>;STMT=</pre>
<p>The option component of the connection string is formed by any or OR'ing two
or more of the values below:</p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="51%" id="AutoNumber1">
<tr>
<td width="69%"><b>Options that affect the behaviour of Driver</b></td>
<td width="31%" align="right">
<p align="right"><b>Value</b></td>
</tr>
<tr>
<td width="69%">Don't Optimize Column Width</td>
<td width="31%" align="right">1</td>
</tr>
<tr>
<td width="69%">Return Matching Rows</td>
<td width="31%" align="right">2</td>
</tr>
<tr>
<td width="69%">Allow BIG Results</td>
<td width="31%" align="right">8</td>
</tr>
<tr>
<td width="69%">Use Compressed Protocol</td>
<td width="31%" align="right">2048</td>
</tr>
<tr>
<td width="69%">Change BIGINT Columns to INT</td>
<td width="31%" align="right">16384</td>
</tr>
<tr>
<td width="69%">Safety (Check this if you have problems)</td>
<td width="31%" align="right">131072</td>
</tr>
<tr>
<td width="69%"><b>Miscellaneous Options</b></td>
<td width="31%" align="right"><b>Value</b></td>
</tr>
<tr>
<td width="69%">Don't Prompt on Connect</td>
<td width="31%" align="right">16</td>
</tr>
<tr>
<td width="69%">Enable Dynamic Cursor</td>
<td width="31%" align="right">32</td>
</tr>
<tr>
<td width="69%">Ignore # in #.Table</td>
<td width="31%" align="right">64</td>
</tr>
<tr>
<td width="69%">Use Manager Cursors</td>
<td width="31%" align="right">128</td>
</tr>
<tr>
<td width="69%">Don't Use Setlocale</td>
<td width="31%" align="right">256</td>
</tr>
<tr>
<td width="69%">Pad CHAR to Full Length</td>
<td width="31%" align="right">512</td>
</tr>
<tr>
<td width="69%">Don't Cache Results (only for forward-only cursors)</td>
<td width="31%" align="right">1048576</td>
</tr>
<tr>
<td width="69%">Return Table names in SQLDescribeCol</td>
<td width="31%" align="right">1024</td>
</tr>
<tr>
<td width="69%">Ignore Space After Function Names</td>
<td width="31%" align="right">4096</td>
</tr>
<tr>
<td width="69%">Force Use of Named Pipes</td>
<td width="31%" align="right">(Unable to check value)</td>
</tr>
<tr>
<td width="69%">No Catalog (exp)</td>
<td width="31%" align="right">32768</td>
</tr>
<tr>
<td width="69%">Read Options from C:\my.cnf</td>
<td width="31%" align="right">65536</td>
</tr>
<tr>
<td width="69%">Disable Transactions</td>
<td width="31%" align="right">262144</td>
</tr>
<tr>
<td width="69%">Force Use of Forward-only Cursors</td>
<td width="31%" align="right">2097152</td>
</tr>
</table>
<p><a href="ado.html#Open()">Back to ADO Tutorial</a></p>
<p> </p>
<p class="cnotice">Copyright 2003-2004 Mark Jundo P. Documento</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -