本實例使用的數據庫名稱為MyFirstAccessDB
把應用程序Example_
<%@ Page language=
AutoEventWireup=
<HEAD><title> Example_
<body MS_POSITIONING=
<form id=
</form>
</body>
</HTML>
把頁面ConnectedAcDB
<appSettings>
<add key=
value=
</add>
</appSettings>
//引入名字空間
using System
//獲取連接字符串
private readonly string ACCESSCONNECTIONSTRING
=ConfigurationSettings
private void Page_Load(object sender
{
if(!Page
{
ConnectAccessDB(); //連接到MyFirstAccessDb數據庫
}
}
private void ConnectAccessDB()
{ //設置訪問數據庫的連接字符串
string accessString = ACCESSCONNECTIONSTRING
+ Server
OleDbConnection accessConn = new OleDbConnection(accessString);
try
{
accessConn
//顯示連接成功信息
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
accessConn
Response
+ accessConn
}
catch(Exception ex)
{
}
}
圖
From:http://tw.wingwit.com/Article/program/net/201311/11767.html