ACCESS宣读写Access数据库演示程序

ACCESS 1

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MyDB
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  p rivate System.Windows.Forms.GroupBox groupBox1;
  p rivate System.Windows.Forms.Button button1;
  p rivate System.Windows.Forms.Button button2;
  p rivate System.Windows.Forms.Button button3;
  p rivate System.Windows.Forms.Button button4;
  p rivate System.Windows.Forms.Button button5;
  p rivate System.Windows.Forms.Button button6;
  p rivate System.Windows.Forms.Button button7;
  p rivate System.Windows.Forms.Button button8;
  p rivate System.Windows.Forms.Button button9;
  p rivate System.Windows.Forms.Label label1;
  p rivate System.Windows.Forms.TextBox textBox1;
  p rivate System.Windows.Forms.TextBox textBox2;
  p rivate System.Windows.Forms.Label label2;
  p rivate System.Windows.Forms.TextBox textBox3;
  p rivate System.Windows.Forms.Label label3;
  p rivate System.Windows.Forms.TextBox textBox4;
  p rivate System.Windows.Forms.Label label4;
  p rivate System.Windows.Forms.TextBox textBox5;
  p rivate System.Windows.Forms.Label label5;
  p rivate System.Windows.Forms.TextBox textBox6;
  pr ivate System.Windows.Forms.Label label6;
  pr ivate System.Windows.Forms.TextBox textBox7;
  pr ivate System.Windows.Forms.Label label7;
  pr ivate System.Windows.Forms.TextBox textBox8;
  pr ivate System.Windows.Forms.Label label8;
  pr ivate System.Windows.Forms.TextBox textBox9;
  pr ivate System.Windows.Forms.Label label9;
  pr ivate System.Windows.Forms.TextBox textBox10;
  pr ivate System.Windows.Forms.Label label10;
  p rivate System.Windows.Forms.TextBox textBox11;
  p rivate System.Windows.Forms.Label label11;
  p rivate System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
  p rivate System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
  p rivate System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
  p rivate System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
  p rivate System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
  p rivate System.Data.OleDb.OleDbConnection oleDbConnection1;
  p rivate BindingManagerBase MyBind;
  p rivate System.Data.OleDb.OleDbCommand oleDbCommand1;
  p rivate System.Data.DataSet dataSet1;
  
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  p rivate System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必备的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后补充加另构造函数代码
   //
  }

  /// <summary>
  /// 清理所有方利用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所欲的章程 – 不要动代码编辑器修改
  /// 此措施的内容。
  /// </summary>
  p rivate void InitializeComponent()
  {
   this.groupBox1 = new System.Windows.Forms.GroupBox();
   this.textBox9 = new System.Windows.Forms.TextBox();
   this.label9 = new System.Windows.Forms.Label();
   this.textBox10 = new System.Windows.Forms.TextBox();
   this.label10 = new System.Windows.Forms.Label();
   this.textBox11 = new System.Windows.Forms.TextBox();
   this.label11 = new System.Windows.Forms.Label();
   this.textBox8 = new System.Windows.Forms.TextBox();
   this.label8 = new System.Windows.Forms.Label();
   this.textBox7 = new System.Windows.Forms.TextBox();
   this.label7 = new System.Windows.Forms.Label();
   this.textBox6 = new System.Windows.Forms.TextBox();
   this.label6 = new System.Windows.Forms.Label();
   this.textBox5 = new System.Windows.Forms.TextBox();
   this.label5 = new System.Windows.Forms.Label();
   this.textBox4 = new System.Windows.Forms.TextBox();
   this.label4 = new System.Windows.Forms.Label();
   this.textBox3 = new System.Windows.Forms.TextBox();
   this.label3 = new System.Windows.Forms.Label();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.label2 = new System.Windows.Forms.Label();
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.label1 = new System.Windows.Forms.Label();
   this.button1 = new System.Windows.Forms.Button();
   this.button2 = new System.Windows.Forms.Button();
   this.button3 = new System.Windows.Forms.Button();
   this.button4 = new System.Windows.Forms.Button();
   this.button5 = new System.Windows.Forms.Button();
   this.button6 = new System.Windows.Forms.Button();
   this.button7 = new System.Windows.Forms.Button();
   this.button8 = new System.Windows.Forms.Button();
   this.button9 = new System.Windows.Forms.Button();
   this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
   this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
   this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
   this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
   this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
   this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
   this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
   this.dataSet1 = new System.Data.DataSet();
   this.groupBox1.SuspendLayout();
   ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
   this.SuspendLayout();
   //
   // groupBox1
   //
   this.groupBox1.Controls.Add(this.textBox9);
   this.groupBox1.Controls.Add(this.label9);
   this.groupBox1.Controls.Add(this.textBox10);
   this.groupBox1.Controls.Add(this.label10);
   this.groupBox1.Controls.Add(this.textBox11);
   this.groupBox1.Controls.Add(this.label11);
   this.groupBox1.Controls.Add(this.textBox8);
   this.groupBox1.Controls.Add(this.label8);
   this.groupBox1.Controls.Add(this.textBox7);
   this.groupBox1.Controls.Add(this.label7);
   this.groupBox1.Controls.Add(this.textBox6);
   this.groupBox1.Controls.Add(this.label6);
   this.groupBox1.Controls.Add(this.textBox5);
   this.groupBox1.Controls.Add(this.label5);
   this.groupBox1.Controls.Add(this.textBox4);
   this.groupBox1.Controls.Add(this.label4);
   this.groupBox1.Controls.Add(this.textBox3);
   this.groupBox1.Controls.Add(this.label3);
   this.groupBox1.Controls.Add(this.textBox2);
   this.groupBox1.Controls.Add(this.label2);
   this.groupBox1.Controls.Add(this.textBox1);
   this.groupBox1.Controls.Add(this.label1);
   this.groupBox1.Location = new System.Drawing.Point(8, 8);
   this.groupBox1.Name = “groupBox1”;
   this.groupBox1.Size = new System.Drawing.Size(352, 224);
   this.groupBox1.TabIndex = 0;
   this.groupBox1.TabStop = false;
   this.groupBox1.Text = “数据库信息”;
   //
   // textBox9
   //
   this.textBox9.Location = new System.Drawing.Point(232, 192);
   this.textBox9.Name = “textBox9”;
   this.textBox9.Size = new System.Drawing.Size(112, 21);
   this.textBox9.TabIndex = 21;
   this.textBox9.Text = “”;
   //
   // label9
   //
   this.label9.Location = new System.Drawing.Point(184, 200);
   this.label9.Name = “label9”;
   this.label9.Size = new System.Drawing.Size(48, 16);
   this.label9.TabIndex = 20;
   this.label9.Text = “传真:”;
   //
   // textBox10
   //
   this.textBox10.Location = new System.Drawing.Point(72, 192);
   this.textBox10.Name = “textBox10”;
   this.textBox10.Size = new System.Drawing.Size(104, 21);
   this.textBox10.TabIndex = 19;
   this.textBox10.Text = “”;
   //
   // label10
   //
   this.label10.Location = new System.Drawing.Point(8, 200);
   this.label10.Name = “label10”;
   this.label10.Size = new System.Drawing.Size(48, 16);
   this.label10.TabIndex = 18;
   this.label10.Text = “电话:”;
   //
   // textBox11
   //
   this.textBox11.Location = new System.Drawing.Point(232, 168);
   this.textBox11.Name = “textBox11”;
   this.textBox11.Size = new System.Drawing.Size(112, 21);
   this.textBox11.TabIndex = 17;
   this.textBox11.Text = “”;
   //
   // label11
   //
   this.label11.Location = new System.Drawing.Point(184, 176);
   this.label11.Name = “label11”;
   this.label11.Size = new System.Drawing.Size(48, 16);
   this.label11.TabIndex = 16;
   this.label11.Text = “国家:”;
   //
   // textBox8
   //
   this.textBox8.Location = new System.Drawing.Point(72, 168);
   this.textBox8.Name = “textBox8”;
   this.textBox8.Size = new System.Drawing.Size(104, 21);
   this.textBox8.TabIndex = 15;
   this.textBox8.Text = “”;
   //
   // label8
   //
   this.label8.Location = new System.Drawing.Point(8, 176);
   this.label8.Name = “label8”;
   this.label8.Size = new System.Drawing.Size(72, 16);
   this.label8.TabIndex = 14;
   this.label8.Text = “邮政编码:”;
   //
   // textBox7
   //
   this.textBox7.Location = new System.Drawing.Point(232, 144);
   this.textBox7.Name = “textBox7”;
   this.textBox7.Size = new System.Drawing.Size(112, 21);
   this.textBox7.TabIndex = 13;
   this.textBox7.Text = “”;
   //
   // label7
   //
   this.label7.Location = new System.Drawing.Point(184, 152);
   this.label7.Name = “label7”;
   this.label7.Size = new System.Drawing.Size(48, 16);
   this.label7.TabIndex = 12;
   this.label7.Text = “地区:”;
   //
   // textBox6
   //
   this.textBox6.Location = new System.Drawing.Point(72, 144);
   this.textBox6.Name = “textBox6”;
   this.textBox6.Size = new System.Drawing.Size(104, 21);
   this.textBox6.TabIndex = 11;
   this.textBox6.Text = “”;
   //
   // label6
   //
   this.label6.Location = new System.Drawing.Point(8, 152);
   this.label6.Name = “label6”;
   this.label6.Size = new System.Drawing.Size(48, 16);
   this.label6.TabIndex = 10;
   this.label6.Text = “城市:”;
   //
   // textBox5
   //
   this.textBox5.Location = new System.Drawing.Point(88, 120);
   this.textBox5.Name = “textBox5”;
   this.textBox5.Size = new System.Drawing.Size(256, 21);
   this.textBox5.TabIndex = 9;
   this.textBox5.Text = “”;
   //
   // label5
   //
   this.label5.Location = new System.Drawing.Point(8, 128);
   this.label5.Name = “label5”;
   this.label5.Size = new System.Drawing.Size(72, 16);
   this.label5.TabIndex = 8;
   this.label5.Text = “联系地址:”;
   //
   // textBox4
   //
   this.textBox4.Location = new System.Drawing.Point(88, 96);
   this.textBox4.Name = “textBox4”;
   this.textBox4.Size = new System.Drawing.Size(256, 21);
   this.textBox4.TabIndex = 7;
   this.textBox4.Text = “”;
   //
   // label4
   //
   this.label4.Location = new System.Drawing.Point(8, 104);
   this.label4.Name = “label4”;
   this.label4.Size = new System.Drawing.Size(80, 16);
   this.label4.TabIndex = 6;
   this.label4.Text = “联系人头衔:”;
   //
   // textBox3
   //
   this.textBox3.Location = new System.Drawing.Point(88, 72);
   this.textBox3.Name = “textBox3”;
   this.textBox3.Size = new System.Drawing.Size(256, 21);
   this.textBox3.TabIndex = 5;
   this.textBox3.Text = “”;
   //
   // label3
   //
   this.label3.Location = new System.Drawing.Point(8, 80);
   this.label3.Name = “label3”;
   this.label3.Size = new System.Drawing.Size(80, 16);
   this.label3.TabIndex = 4;
   this.label3.Text = “联系人姓名:”;
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(88, 48);
   this.textBox2.Name = “textBox2”;
   this.textBox2.Size = new System.Drawing.Size(256, 21);
   this.textBox2.TabIndex = 3;
   this.textBox2.Text = “”;
   //
   // label2
   //
   this.label2.Location = new System.Drawing.Point(8, 56);
   this.label2.Name = “label2”;
   this.label2.Size = new System.Drawing.Size(72, 16);
   this.label2.TabIndex = 2;
   this.label2.Text = “公司称:”;
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(88, 24);
   this.textBox1.Name = “textBox1”;
   this.textBox1.Size = new System.Drawing.Size(256, 21);
   this.textBox1.TabIndex = 1;
   this.textBox1.Text = “”;
   //
   // label1
   //
   this.label1.Location = new System.Drawing.Point(8, 32);
   this.label1.Name = “label1”;
   this.label1.Size = new System.Drawing.Size(56, 16);
   this.label1.TabIndex = 0;
   this.label1.Text = “客户ID:”;
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(368, 16);
   this.button1.Name = “button1”;
   this.button1.TabIndex = 1;
   this.button1.Text = “第一久记下”;
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // button2
   //
   this.button2.Location = new System.Drawing.Point(368, 40);
   this.button2.Name = “button2”;
   this.button2.TabIndex = 2;
   this.button2.Text = “前无异长长的记下”;
   this.button2.Click += new System.EventHandler(this.button2_Click);
   //
   // button3
   //
   this.button3.Location = new System.Drawing.Point(368, 64);
   this.button3.Name = “button3”;
   this.button3.TabIndex = 3;
   this.button3.Text = “后一样长记下”;
   this.button3.Click += new System.EventHandler(this.button3_Click);
   //
   // button4
   //
   this.button4.Location = new System.Drawing.Point(368, 88);
   this.button4.Name = “button4”;
   this.button4.TabIndex = 4;
   this.button4.Text = “末一漫长记下”;
   this.button4.Click += new System.EventHandler(this.button4_Click);
   //
   // button5
   //
   this.button5.Location = new System.Drawing.Point(368, 112);
   this.button5.Name = “button5”;
   this.button5.TabIndex = 5;
   this.button5.Text = “新建记录”;
   this.button5.Click += new System.EventHandler(this.button5_Click);
   //
   // button6
   //
   this.button6.Location = new System.Drawing.Point(368, 136);
   this.button6.Name = “button6”;
   this.button6.TabIndex = 6;
   this.button6.Text = “增加记录”;
   this.button6.Click += new System.EventHandler(this.button6_Click);
   //
   // button7
   //
   this.button7.Location = new System.Drawing.Point(368, 160);
   this.button7.Name = “button7”;
   this.button7.TabIndex = 7;
   this.button7.Text = “修改记录”;
   this.button7.Click += new System.EventHandler(this.button7_Click);
   //
   // button8
   //
   this.button8.Location = new System.Drawing.Point(368, 184);
   this.button8.Name = “button8”;
   this.button8.TabIndex = 2;
   this.button8.Text = “删除记录”;
   this.button8.Click += new System.EventHandler(this.button8_Click);
   //
   // button9
   //
   this.button9.Location = new System.Drawing.Point(368, 208);
   this.button9.Name = “button9”;
   this.button9.TabIndex = 8;
   this.button9.Text = “关闭程序”;
   this.button9.Click += new System.EventHandler(this.button9_Click);
   //
   // oleDbDataAdapter1
   //
   this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
   this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
   this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
   this.oleDbDataAdapter1.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
                          new
System.Data.Common.DataTableMapping(“Table”, “客户”, new
System.Data.Common.DataColumnMapping[] {
                                                     new
System.Data.Common.DataColumnMapping(“城市”, “城市”),
                                                     new
System.Data.Common.DataColumnMapping(“传真”, “传真”),
                                                     new
System.Data.Common.DataColumnMapping(“地区”, “地区”),
                                                     new
System.Data.Common.DataColumnMapping(“地址”, “地址”),
                                                     new
System.Data.Common.DataColumnMapping(“电话”, “电话”),
                                                     new
System.Data.Common.DataColumnMapping(“公司称”, “公司称”),
                                                     new
System.Data.Common.DataColumnMapping(“国家”, “国家”),
                                                     new
System.Data.Common.DataColumnMapping(“客户ID”, “客户ID”),
                                                     new
System.Data.Common.DataColumnMapping(“联系人头衔”, “联系人头衔”),
                                                     new
System.Data.Common.DataColumnMapping(“联系人姓名”, “联系人姓名”),
                                                     new
System.Data.Common.DataColumnMapping(“邮政编码”, “邮政编码”)})});
   this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
   //
   // oleDbDeleteCommand1
   //
   this.oleDbDeleteCommand1.CommandText = @”DELETE FROM 客户 WHERE
(客户ID = ?) AND (传真 = ? OR ? IS NULL AND 传真 IS NULL) AND (公司称
= ?) AND (国家 = ? OR ? IS NULL AND 国家 IS NULL) AND (地区 = ? OR ? IS
NULL AND 地区 IS NULL) AND (地址 = ? OR ? IS NULL AND 地址 IS NULL) AND
(城市 = ? OR ? IS NULL AND 城市 IS NULL) AND (电话 = ? OR ? IS NULL AND
电话 IS NULL) AND (联系人头衔 = ? OR ? IS NULL AND 联系人头衔 IS NULL)
AND (联系人姓名 = ? OR ? IS NULL AND 联系人姓名 IS NULL) AND (邮政编码 =
? OR ? IS NULL AND 邮政编码 IS NULL)”;
   this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_客户ID”,
System.Data.OleDb.OleDbType.VarWChar, 5,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “客户ID”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_传真”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “传真”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_传真1”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “传真”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_店名称”,
System.Data.OleDb.OleDbType.VarWChar, 40,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “公司名称”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_国家”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “国家”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_国家1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “国家”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地区”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地区”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地区1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地区”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地址”,
System.Data.OleDb.OleDbType.VarWChar, 60,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地址”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地址1”,
System.Data.OleDb.OleDbType.VarWChar, 60,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地址”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_城市”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “城市”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_城市1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “城市”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_电话”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “电话”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_电话1”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “电话”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_联络人头衔”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人头衔”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_沟通人头衔1”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人头衔”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_关系人姓名”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人姓名”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_关系人姓名1”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人姓名”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_邮政编码”,
System.Data.OleDb.OleDbType.VarWChar, 10,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “邮政编码”, System.Data.DataRowVersion.Original,
null));
   this.oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_邮编1”,
System.Data.OleDb.OleDbType.VarWChar, 10,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “邮政编码”, System.Data.DataRowVersion.Original,
null));
   //
   // oleDbConnection1
   //
   this.oleDbConnection1.ConnectionString = @”Jet OLEDB:Global Partial
Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking
Mode=1;Jet OLEDB:Database Password=;Data
Source=””Northwind.mdb””;Password=;Jet OLEDB:Engine Type=5;Jet
OLEDB:Global Bulk
Transactions=1;Provider=””Microsoft.Jet.OLEDB.4.0″”;Jet OLEDB:System
database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny
None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;Jet OLEDB:Don’t Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet
OLEDB:Encrypt Database=False”;
   //
   // oleDbInsertCommand1
   //
   this.oleDbInsertCommand1.CommandText = “INSERT INTO 客户(城市, 传真,
地区, 地址, 电话, 公司名, 国家, 客户ID, 联系人头衔, 联系人姓名,
邮政编码) VALUES (?,” +
    ” ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”;
   this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“城市”,
System.Data.OleDb.OleDbType.VarWChar, 15, “城市”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“传真”,
System.Data.OleDb.OleDbType.VarWChar, 24, “传真”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“地区”,
System.Data.OleDb.OleDbType.VarWChar, 15, “地区”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“地址”,
System.Data.OleDb.OleDbType.VarWChar, 60, “地址”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“电话”,
System.Data.OleDb.OleDbType.VarWChar, 24, “电话”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“公司称”,
System.Data.OleDb.OleDbType.VarWChar, 40, “公司名称”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“国家”,
System.Data.OleDb.OleDbType.VarWChar, 15, “国家”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“客户ID”,
System.Data.OleDb.OleDbType.VarWChar, 5, “客户ID”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“联系人头衔”,
System.Data.OleDb.OleDbType.VarWChar, 30, “联系人头衔”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“联系人姓名”,
System.Data.OleDb.OleDbType.VarWChar, 30, “联系人姓名”));
   this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“邮政编码”,
System.Data.OleDb.OleDbType.VarWChar, 10, “邮政编码”));
   //
   // oleDbSelectCommand1
   //
   this.oleDbSelectCommand1.CommandText = “SELECT 城市, 传真, 地区,
地址, 电话, 公司名, 国家, 客户ID, 联系人头衔, 联系人姓名, 邮政编码
FROM 客户”;
   this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
   //
   // oleDbUpdateCommand1
   //
   this.oleDbUpdateCommand1.CommandText = @”UPDATE 客户 SET 城市 = ?,
传真 = ?, 地区 = ?, 地址 = ?, 电话 = ?, 公司名 = ?, 国家 = ?, 客户ID =
?, 联系人头衔 = ?, 联系人姓名 = ?, 邮政编码 = ? WHERE (客户ID = ?) AND
(传真 = ? OR ? IS NULL AND 传真 IS NULL) AND (公司称 = ?) AND (国家 =
? OR ? IS NULL AND 国家 IS NULL) AND (地区 = ? OR ? IS NULL AND 地区 IS
NULL) AND (地址 = ? OR ? IS NULL AND 地址 IS NULL) AND (城市 = ? OR ? IS
NULL AND 城市 IS NULL) AND (电话 = ? OR ? IS NULL AND 电话 IS NULL) AND
(联系人头衔 = ? OR ? IS NULL AND 联系人头衔 IS NULL) AND (联系人姓名 = ?
OR ? IS NULL AND 联系人姓名 IS NULL) AND (邮政编码 = ? OR ? IS NULL AND
邮政编码 IS NULL)”;
   this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“城市”,
System.Data.OleDb.OleDbType.VarWChar, 15, “城市”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“传真”,
System.Data.OleDb.OleDbType.VarWChar, 24, “传真”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“地区”,
System.Data.OleDb.OleDbType.VarWChar, 15, “地区”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“地址”,
System.Data.OleDb.OleDbType.VarWChar, 60, “地址”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“电话”,
System.Data.OleDb.OleDbType.VarWChar, 24, “电话”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“公司称”,
System.Data.OleDb.OleDbType.VarWChar, 40, “公司名称”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“国家”,
System.Data.OleDb.OleDbType.VarWChar, 15, “国家”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“客户ID”,
System.Data.OleDb.OleDbType.VarWChar, 5, “客户ID”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“联系人头衔”,
System.Data.OleDb.OleDbType.VarWChar, 30, “联系人头衔”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“联系人姓名”,
System.Data.OleDb.OleDbType.VarWChar, 30, “联系人姓名”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“邮政编码”,
System.Data.OleDb.OleDbType.VarWChar, 10, “邮政编码”));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_客户ID”,
System.Data.OleDb.OleDbType.VarWChar, 5,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “客户ID”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_传真”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “传真”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_传真1”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “传真”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_信用社称”,
System.Data.OleDb.OleDbType.VarWChar, 40,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “公司称”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_国家”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “国家”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_国家1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “国家”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地区”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地区”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地区1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地区”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地址”,
System.Data.OleDb.OleDbType.VarWChar, 60,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地址”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_地址1”,
System.Data.OleDb.OleDbType.VarWChar, 60,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “地址”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_城市”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “城市”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_城市1”,
System.Data.OleDb.OleDbType.VarWChar, 15,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “城市”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_电话”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “电话”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_电话1”,
System.Data.OleDb.OleDbType.VarWChar, 24,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “电话”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_联系人头衔”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人头衔”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_联络人头衔1”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人头衔”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_沟通人姓名”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人姓名”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_沟通人姓名1”,
System.Data.OleDb.OleDbType.VarWChar, 30,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “联系人姓名”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_邮政编码”,
System.Data.OleDb.OleDbType.VarWChar, 10,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “邮政编码”, System.Data.DataRowVersion.Original,
null));
   this.oleDbUpdateCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter(“Original_邮政编码1”,
System.Data.OleDb.OleDbType.VarWChar, 10,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), “邮政编码”, System.Data.DataRowVersion.Original,
null));
   //
   // dataSet1
   //
   this.dataSet1.DataSetName = “NewDataSet”;
   this.dataSet1.Locale = new
System.Globalization.CultureInfo(“zh-CN”);
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(448, 238);
   this.Controls.Add(this.button9);
   this.Controls.Add(this.button7);
   this.Controls.Add(this.button6);
   this.Controls.Add(this.button5);
   this.Controls.Add(this.button4);
   this.Controls.Add(this.button3);
   this.Controls.Add(this.button2);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.groupBox1);
   this.Controls.Add(this.button8);
   this.MaximizeBox = false;
   this.Name = “Form1”;
   this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = “演示读写ACCESS数据库”;
   this.Load += new System.EventHandler(this.Form1_Load);
   this.groupBox1.ResumeLayout(false);
   ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  p rivate void Form1_Load(object sender, System.EventArgs e)
  {//初始化数据集
   try
   {
    this.oleDbDataAdapter1.Fill(this.dataSet1,”客户”);
    this.textBox1.DataBindings.Add(“Text”,this.dataSet1,”客户.客户ID”);
    this.textBox2.DataBindings.Add(“Text”,this.dataSet1,”客户.公司称”);
    this.textBox3.DataBindings.Add(“Text”,this.dataSet1,”客户.联系人姓名”);
    this.textBox4.DataBindings.Add(“Text”,this.dataSet1,”客户.联系人头衔”);
    this.textBox5.DataBindings.Add(“Text”,this.dataSet1,”客户.地址”);
    this.textBox6.DataBindings.Add(“Text”,this.dataSet1,”客户.城市”);
    this.textBox7.DataBindings.Add(“Text”,this.dataSet1,”客户.地区”);
    this.textBox8.DataBindings.Add(“Text”,this.dataSet1,”客户.邮政编码”);
    this.textBox9.DataBindings.Add(“Text”,this.dataSet1,”客户.国家”);
    this.textBox10.DataBindings.Add(“Text”,this.dataSet1,”客户.电话”);
    this.textBox11.DataBindings.Add(“Text”,this.dataSet1,”客户.传真”);
    this.MyBind=this.BindingContext[this.dataSet1,”客户”];
   }
   catch(Exception Err)
   {
    MessageBox.Show(“打开数据库表错误:”+Err.Message,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   } 
  }
  p rivate void button1_Click(object sender, System.EventArgs e)
  {//第一长达记下
   this.MyBind.Position=0;  
  }
  p rivate void button2_Click(object sender, System.EventArgs e)
  {//前同样长长的记下
   if(this.MyBind.Position==0)
   {
    MessageBox.Show(“已经是首先漫长记下”,”信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   else
    this.MyBind.Position–;
  }

  p rivate void button3_Click(object sender, System.EventArgs e)
  {//后一致修记下
   if(this.MyBind.Position==this.MyBind.Count-1)
   {
    MessageBox.Show(“已经是终极一久记下”,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   else
    this.MyBind.Position++;
  
  }

  p rivate void button4_Click(object sender, System.EventArgs e)
  {//末同长长的记下
   this.MyBind.Position=this.MyBind.Count-1;
  }

  p rivate void button5_Click(object sender, System.EventArgs e)
  {//新建记录
   this.textBox1.Text=””;
   this.textBox2.Text=””;
   this.textBox3.Text=””;
   this.textBox4.Text=””;
   this.textBox5.Text=””;
   this.textBox6.Text=””;
   this.textBox7.Text=””;
   this.textBox8.Text=””;
   this.textBox9.Text=””;
   this.textBox10.Text=””;
   this.textBox11.Text=””;   
  }

  p rivate void button6_Click(object sender, System.EventArgs e)
  {//增加记录
   if(this.textBox1.Text.Length<1|this.textBox2.Text.Length<1|this.textBox3.Text.Length<1|
    this.textBox4.Text.Length<1|this.textBox5.Text.Length<1|this.textBox6.Text.Length<1|
    this.textBox7.Text.Length<1|this.textBox8.Text.Length<1|this.textBox9.Text.Length<1|
    this.textBox10.Text.Length<1|this.textBox11.Text.Length<1)
   {
    MessageBox.Show(“客户有信息要填写!”,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   try
   {
    string StrSQL=”INSERT INTO
客户(客户ID,公司称,联系人姓名,联系人头衔,地址,城市,地区,邮政编码,国家,电话,传真)VALUES(‘”;
    StrSQL+=this.textBox1.Text+”‘,'”;
    StrSQL+=this.textBox2.Text+”‘,'”;
    StrSQL+=this.textBox3.Text+”‘,'”;
    StrSQL+=this.textBox4.Text+”‘,'”;
    StrSQL+=this.textBox5.Text+”‘,'”;
    StrSQL+=this.textBox6.Text+”‘,'”;
    StrSQL+=this.textBox7.Text+”‘,'”;
    StrSQL+=this.textBox8.Text+”‘,'”;
    StrSQL+=this.textBox9.Text+”‘,'”;
    StrSQL+=this.textBox10.Text+”‘,'”;
    StrSQL+=this.textBox11.Text+”‘)”;    
    this.oleDbCommand1.CommandText=StrSQL;
    this.oleDbCommand1.Connection=this.oleDbConnection1;
    //打开数据库连接
    this.oleDbConnection1.Open();
    //执行SQL命令
    this.oleDbCommand1.ExecuteNonQuery();
    //关闭连接
    this.oleDbConnection1.Close();
    //更新数据集
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].BeginEdit();
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].EndEdit();    
    this.dataSet1.AcceptChanges();
    MessageBox.Show(“增加多少集记录操作成!”,”信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception Err)
   {
    MessageBox.Show(“增加数据集记录操作失败:”+Err.Message,”信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    //如果打开了连接,则关闭它
    if(this.oleDbConnection1.State==ConnectionState.Open)
    {
     this.oleDbConnection1.Close();
    }
   }  
  }

  p rivate void button7_Click(object sender, System.EventArgs e)
  {//修改记录
   if(this.textBox1.Text.Length<1)
   {
    MessageBox.Show(“客户ID必须填写!”,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   try
   {
    string StrSQL=”UPDATE 客户 SET”;
    StrSQL+=” 公司名称='”+this.textBox2.Text;
    StrSQL+=”‘, 联系人姓名='”+this.textBox3.Text;
    StrSQL+=”‘, 联系人头衔='”+this.textBox4.Text;
    StrSQL+=”‘, 地址='”+this.textBox5.Text;
    StrSQL+=”‘, 城市='”+this.textBox6.Text;
    StrSQL+=”‘, 地区='”+this.textBox7.Text;
    StrSQL+=”‘, 邮政编码='”+this.textBox8.Text;
    StrSQL+=”‘, 国家='”+this.textBox9.Text;
    StrSQL+=”‘, 电话='”+this.textBox10.Text;
    StrSQL+=”‘, 传真='”+this.textBox11.Text+”‘ WHERE 
客户ID='”+this.textBox1.Text+”‘”;
    this.oleDbCommand1.CommandText=StrSQL;
    this.oleDbCommand1.Connection=this.oleDbConnection1;
    //打开数据库连接
    this.oleDbConnection1.Open();
    //执行SQL命令
    this.oleDbCommand1.ExecuteNonQuery();
    //关闭连接
    this.oleDbConnection1.Close();
    //更新数据集
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].BeginEdit();
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].EndEdit();    
    this.dataSet1.AcceptChanges();
    this.oleDbDataAdapter1.Fill(this.dataSet1,”客户”);
    MessageBox.Show(“修改数据集记录操作成!”,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception Err)
   {
    MessageBox.Show(“修改数据集记录操作失败:”+Err.Message,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    //如果打开了连续,则关闭它
    if(this.oleDbConnection1.State==ConnectionState.Open)
    {
     this.oleDbConnection1.Close();
    }
   }    
  }

  p rivate void button8_Click(object sender, System.EventArgs e)
  {//删除记录
   try
   {
    string StrSQL=”DELETE FROM  客户 WHERE “;
    StrSQL+=” 客户ID='”+this.textBox1.Text+”‘”;    
    this.oleDbCommand1.CommandText=StrSQL;
    this.oleDbCommand1.Connection=this.oleDbConnection1;
    //打开数据库连接
    this.oleDbConnection1.Open();
    //执行SQL命令
    this.oleDbCommand1.ExecuteNonQuery();
    //关闭连接
    this.oleDbConnection1.Close();
    //更新数据集
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].BeginEdit();
    this.dataSet1.Tables[“客户”].Rows[this.MyBind.Position].EndEdit();    
    this.dataSet1.AcceptChanges();
    this.oleDbDataAdapter1.Fill(this.dataSet1,”客户”);
    this.MyBind.Position=0;
    MessageBox.Show(“删除数据集记录操作成!”,”信息提醒”,MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception Err)
   {
    MessageBox.Show(“删除数据集记录操作失败:”+Err.Message,”信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
    //如果打开了连接,则关闭它
    if(this.oleDbConnection1.State==ConnectionState.Open)
    {
     this.oleDbConnection1.Close();
    }
   }      
  }

  p rivate void button9_Click(object sender, System.EventArgs e)
  {//关闭程序
   //如果打开了连年,则关闭它
   if(this.oleDbConnection1.State==ConnectionState.Open)
   {
    this.oleDbConnection1.Close();
   }
   this.Close();  
  }

 }
}
 

 

相关文章