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
//顯示連接成功信息
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
Response
+ accessConn
//執行數據庫的操作
accessConn
Response
+ accessConn
}
catch(Exception ex)
{
Response
}
}
設置頁面ConnectedAcDB
圖
[
From:http://tw.wingwit.com/Article/program/net/201311/15197.html