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

📄 ado_connect.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>ADO Database Connection</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>


<h1>ADO Database Connection</h1>
<a href="ado_intro.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="ado_recordset.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />

<p class="intro">Before a database can be accessed from a web page, a database connection has
to be established.</p>
<hr />
<h2>Create a DSN-less Database Connection</h2>
<p>The easiest way to connect to a database is to use a DSN-less connection. A
DSN-less connection can be used against any Microsoft Access database on your web site.</p>
<p>If you have a database called &quot;northwind.mdb&quot; located in a web
directory like &quot;c:/webdata/&quot;,
you can connect to the database with the following ASP code:</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr>
    <td>
      <pre>&lt;%
set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Provider=&quot;Microsoft.Jet.OLEDB.4.0&quot;
conn.Open &quot;c:/webdata/northwind.mdb&quot;
%&gt;</pre>
    </td>
  </tr>
</table>
<p>
Note, from the example above, that you have to specify the Microsoft Access
database driver (Provider) and the physical path to the database on your
computer.</p>
<hr />
<h2>Create an ODBC Database Connection</h2>
<p>If you have an ODBC database called &quot;northwind&quot; you can connect to the database with the following
ASP code:</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr>
    <td>
      <pre>&lt;%
set conn=Server.CreateObject(&quot;ADODB.Connection&quot;) 
conn.Open &quot;northwind&quot;
%&gt;</pre>
    </td>
  </tr>
</table>
<p>
With an ODBC connection, you can connect to any database, on any computer in
your network, as long as an ODBC connection is available.</p>
<hr />
<h2>An ODBC Connection to an MS Access Database</h2>
<p>Here is how to create a connection to a MS Access Database:&nbsp;</p>
<ol>
  <li>Open the <b>ODBC</b> icon in your Control Panel.</li>
  <li>Choose the <b>System DSN</b> tab.</li>
  <li>Click on <b> Add </b>in the System DSN tab.</li>
  <li><b>Select</b> the Microsoft Access Driver. Click <b>Finish.</b></li>
  <li>In the next screen, click <b> Select</b> to locate the database.</li>
  <li>Give the database a <b>D</b>ata <b>S</b>ource <b>N</b>ame (DSN).</li>
  <li>Click <b> OK</b>.</li>
</ol>
<p>Note that this configuration has to be done on the computer where your web site
is located. If you are running Personal Web Server (PWS)
or Internet Information Server (IIS) on your own computer,
the instructions above will work, but if your web site is located on a remote server, you have to
have physical access to that server, or ask your web
host to do this for you.&nbsp;</p>
<hr />
<h2>The ADO Connection Object</h2>
<p>The ADO Connection object is used to create an open connection to a data
source.&nbsp;Through this connection, you can access and manipulate a database.</p>

<p><a href="ado_ref_connection.asp">View all methods and properties of the Connection object</a>.</p>
<hr />
<a href="ado_intro.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="ado_recordset.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

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