private void Page_Load(object sender
{
if(!Page
{
ShowDBData(); //顯示數據庫MyFirstAccessDB中的數據
}
}
private void ShowDBData()
{ //設在訪問數據庫的連接字符串
string accessString = ACCESSCONNECTIONSTRING
+ Server
string cmdText =
//創建數據庫的連接和Command
OleDbConnection accessConn = new OleDbConnection(accessString);
OleDbCommand accessComm = new OleDbCommand(cmdText
//定義數據顯示的格式
string dataString =
try
{ //打開OLEDB數據庫的連接
accessConn
Response
//顯示數據庫中的信息
OleDbDataReader reca = accessComm
while(reca
{ //獲取相應數據
dataString += reca[
+ reca[
+
+ reca[
dataString +=
}
reca
Response
accessConn
}
catch(Exception ex)
{
Response
}
}
設置頁面ShowData
right
From:http://tw.wingwit.com/Article/program/net/201311/15168.html