日期:2014-05-18  浏览次数:20945 次

WinForm下如何直接对Access数据库进行增删改操作啊?大虾们要帮我啊!!!小弟先谢了
winform下,我用DataGirdView绑定到Access数据库,想直接对数据库进行增删改操作,请问各位大虾如何做?
看了好多贴子,没明白。最好能给个例子看看,谢谢了!!

------解决方案--------------------
用OleDB连接就行了呀,跟操作mssql一样的
------解决方案--------------------
using System.data.oledb

public void UpdateDB(Dataset ds){
OledbConnection myCon = new OledbConnection(con.conntionstring);
Transaction tran;
mycon.open()
tran = mycon.begintransaction;

try{
String sql = "Select * from table";
OledbCommand cmd = new OledbCommand(sql,myCon,tran);
Oledbdataadapter adapter = new oledbdataadapter(cmd);
CommandBuilder cb = new CommandBuilder(adapter);
adapter.update(ds.table(tablename));
tran.commit();
}catch(DBConcurrencyExcetion cex){
tran.rollback();
/并发处理
}catch(Excetion ex){
tran.rollback();
throw ex;
}finally{
mycon.close();
}
}