This article mainly describes the net operations Access database sample, the need for friends can refer to the following
Code as follows: using System; Using System.Data; Using System.Configuration; Using System.Linq; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.HtmlControls; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Xml.Linq; Using System.Data.OleDb; ///<summary>///accessdb Summary description///</summary> public class Accessdb { public accessdb () { //todo: Here Add constructor logic } ///<summary> & nbsp ///Read Access database ///</summary> private void Readaccessdata () {&nbs P //1, establishing connection String saccessconnection = @ "Provider=microsoft.jet.oledb.4.0;d ATA source=c:documents and settingsadministrator.www-410adc78208 desktop applications. mdb "; OleDbConnection odcconnection = new OleDbConnection (saccessconnection); &NBSP //2, open connection Odcconnection.open (); //Set up SQL query OleDbCommand Odcommand = Odcconnection.createcommand (); //3, input query statement Odcommand.commandtext = "Select table. number, table. [123], table. [456] from [table]; "; //Set up read OleDbDataReader odrreader = Odcommand.executereader (); //query and display data while (Odrreader.read ()) {& nbsp ListViewItem item = new ListViewItem (); item. SubItems.Add (Odrreader[0]. ToString ()); item. SubItems.Add (Odrreader[1]. ToString ()); item. SubItems.Add (Odrreader[2]. ToString ()); THIS.LISTVIEW1.ITEMS.ADD (item); } /close connection odrreader.close (); odcconnection.close (); } ///<summary> ///add ///</summary> / <param name= "Sender" ></param> ///<param name= "E" ></param> private void Button1_Click (object sender, EventArgs e) { //1, establishing connection String saccessconnection = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:documents and settingsadministrator.www-410adc78208 desktop applications. mdb "; OleDbConnection odcconnection = new OleDbConnection (saccessconnection); //2, open connection Odcconnection.open (); //Set up SQL query OleDbCommand Odcommand = Odcconnection.createcommand ();   //3, input query statement Odcommand.commandtext = INSERT into [table] ([123],[456]) VALUES (' 88 ', ' 88 ') "; //execute odcommand.executenonquery (); //close connection odcconnection.close (); this.listView1.Items.Clear (); readaccessdata (); } ///<summary> ///Delete ///</summary>   ; ///<param name= "sender" ></param> ///<param name= "E" ></param> private void Button3_Click (object sender, EventArgs e) { //1, establishing connection String saccessconnection = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:documents and settingsadministrator.www-410adc78208 desktop applications. mdb "; OleDbConnection odcconnection = new OleDbConnection (saccessconnection); //2, open connection Odcconnection.open (); //Set up SQL query OleDbCommand Odcommand = Odcconnection.createcommand (); //3, input query statement String sql = "DELETE table." Number from [table] WHERE ((tab Le. Number) = "+ this.listview1.selecteditems[0]." SUBITEMS[1]. Text + ")"; odcommand.commandtext = SQL; //execute odcommand.executenonquery (); //close connection odcconnection.close (); this.listView1.Items.Clear (); readaccessdata (); } ///<summary> ///update ///</summary>   ; ///<param name= "sender" ></param> ///<param name= "E" ></param> private void button2_click (object sender, EventArgs e) { //1, establishing a connection String saccessconnection = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:documents and Se ttingsadministrator.www-410adc78208 desktop applications. mdb "; OleDbConnection odcconnection = new OleDbConnection (saccessconnection); //2, open connection Odcconnection.open (); //Set up SQL query OleDbCommand Odcommand = Odcconnection.createcommand (); //3, input query statement String sql = "UPDATE [table] SET 123= '", 456= ' one ' &nbs P WHERE ((table. Number) = "+ this.listview1.selecteditems[0]. SUBITEMS[1]. Text + ")"; odcommand.commandtext = SQL; //execute odcommand.executenonquery (); //close connection Odcconnection.close (); this.listView1.Items.Clear (); readaccessdata (); }}