access資料庫連線

2021-05-06 17:54:26 字數 1507 閱讀 8564

string strconnection = "provider=microsoft.jet.oledb.4.0;";

strconnection += @"data source=e:/accesstest/data.mdb";//?裡用的是??路徑

oledbconnection objconnection = new oledbconnection(strconnection);

objconnection.open();

//查詢

//oledbdataadapter da = new oledbdataadapter("select * from test", objconnection);

//dataset ds = new dataset();

//da.fill(ds);

//查詢

oledbcommand command = new oledbcommand("select * from test where id = '1'", objconnection);

oledbdataadapter datemp = new oledbdataadapter(command);

dataset dtstemp = new dataset();

datemp.fill(dtstemp);

//追加

oledbcommand insertcommand = new oledbcommand("insert into test(id,name,age) values('4','4','4')", objconnection);

int intinsert = insertcommand.executenonquery();

//更新

oledbcommand updatecommand = new oledbcommand("update test set age = '8' where id =" + ":id", objconnection);

oledbparameter oledbparameter = new oledbparameter("id", "6");

updatecommand.parameters.add(oledbparameter);

//oledbcommand updatecommand = new oledbcommand("update test set age = '8' where id = '6'", objconnection);

int intupdate = updatecommand.executenonquery();

string strtemp = "'" + "/"" + "'";

//刪除

oledbcommand deletecommand = new oledbcommand("delete from test where id = '3'", objconnection);

int intdelete = deletecommand.executenonquery();

objconnection.close();

連線ACCESS資料庫

1 匯入命名空間空間 system.data.oledb 2 建立指向資料庫的連線 建立連線要用到system.data.oledb命名空間中的類 oledbconnection。通過以下語句可以完成對本地資料庫的連線工作 string strconnect provider microsoft.j...

Access資料庫連線

access資料庫的連線,2000和2007版本有差別。access2000的連線字串為 1 2 3 4 str.format text provider microsoft.jet.oledb.4.0 persist security info false data source s szdata...

PERL連線ACCESS資料庫

2001年02月14日 08 20 00 perl連線access資料庫 前題是必須安裝好activeperl 505以上 以及ms access 97 一.安裝win32 odbc模組 步驟1 readme win32 odbc.ppd win32 odbc.tar.gz 步驟2 在dos視窗下,...