⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 C# 使用OLEDB
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Data.OleDb;
using System.Collections.Specialized;
using System.Text;

/// needs to be added through project "add reference"//projects
using GenericOLEDB;

namespace CSHARPOLEDB3
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.TextBox textBox4;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.ListView listView1;

		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button Edit;
		private System.Windows.Forms.Button Insert;

		private System.Windows.Forms.Button Delete;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		///  declare a variable to handle the generic database stuff
		/// </summary>
		private GenericOLEDBClass dbAccess;

		/// <summary>
		/// String Collection to store the column names
		/// </summary>
		private StringCollection stringCol;

		/// <summary>
		/// string holder for the provider
		/// </summary>
		private string strProvider;

		/// <summary>
		/// Get and Set the provider
		/// </summary>
		public string Provider
		{
			get
			{
				return strProvider;
			}
			set
			{
				strProvider = value;
			}
		}

		/// <summary>
		/// string holder for the password
		/// </summary>
		private string strPassword;

		/// <summary>
		/// Get and Set the Password
		/// </summary>
		public string Password
		{
			get
			{
				return strPassword;
			}
			set
			{
				strPassword = value;
			}
		}

		/// <summary>
		/// string holder for the user ID
		/// </summary>
		private string strUserID;

		/// <summary>
		/// Get and Set the User ID
		/// </summary>
		public string UserID
		{
			get
			{
				return strUserID;
			}
			set
			{
				strUserID = value;
			}
		}

		/// <summary>
		/// String holder for the database name
		/// </summary>
		private string strDatabaseName;

		/// <summary>
		/// Get and Set the Database name
		/// </summary>
		public string DatabaseName
		{
			get
			{
				return strDatabaseName;
			}
			set
			{
				strDatabaseName = value;
			}
		}


		/// <summary>
		/// string holder for the mode
		/// </summary>
		private string strMode;

		/// <summary>
		/// Get and Set the Mode
		/// </summary>
		public string Mode
		{
			get
			{
				return strMode;
			}
			set
			{
				strMode = value;
			}
		}

		/// <summary>
		///  Add the strings for the commands
		/// </summary>

		/// <summary>
		/// string holder for the select command
		/// </summary>
		private string strSelect;

		/// <summary>
		///  Get and Set the select Command
		/// </summary>
		public string SelectCommand
		{
			get
			{
				return strSelect;
			}
			set
			{
				strSelect = value;
			}
		}

		/// <summary>
		///  string holder for the Insert Command
		/// </summary>
		private string strInsert;

		/// <summary>
		/// Get and Set the Insert Command
		/// </summary>
		public string InsertCommand
		{
			get
			{
				return strInsert;
			}
			set
			{
				strInsert = value;
			}
		}

		/// <summary>
		/// String holder for the Delete Command
		/// </summary>
		private string strDelete;

		/// <summary>
		/// Get and Set for the Delete Command
		/// </summary>
		public string DeleteCommand
		{
			get
			{
				return strDelete;
			}
			set
			{
				strDelete = value;
			}
		}

		/// <summary>
		/// String holder for the update Command
		/// </summary>
		private string strUpdate;

		private System.Windows.Forms.Button Select_button;

		/// <summary>
		/// Get and Set the Update Command
		/// </summary>
		public string UpdateCommand
		{
			get
			{
				return strUpdate;
			}
			set
			{
				strUpdate = value;
			}
		}

		/// <summary>
		/// string holder for the table
		/// </summary>
		private string strTable;

		/// <summary>
		/// Get and Set the table name
		/// </summary>
		public string Table
		{
			get
			{
				return strTable;
			}
			set 
			{
				strTable = value;
			}
		}


		/// <summary>
		/// Standard constructor
		/// </summary>
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//

			/// set the defaults for an access database
			textBox1.Text = "Microsoft.Jet.OLEDB.4.0";
			textBox2.Text = "Admin";
			textBox3.Text = "";
			Mode = "ReadWrite";

			stringCol = new StringCollection();

		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label3 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox4 = new System.Windows.Forms.TextBox();
			this.Select_button = new System.Windows.Forms.Button();
			this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.listView1 = new System.Windows.Forms.ListView();
			this.Edit = new System.Windows.Forms.Button();
			this.Delete = new System.Windows.Forms.Button();
			this.Insert = new System.Windows.Forms.Button();
			this.label4 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(256, 8);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 16);
			this.label3.TabIndex = 0;
			this.label3.Text = "Password";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(128, 24);
			this.textBox2.Name = "textBox2";
			this.textBox2.TabIndex = 2;
			this.textBox2.Text = "textBox2";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(256, 24);
			this.textBox3.Name = "textBox3";
			this.textBox3.TabIndex = 3;
			this.textBox3.Text = "textBox3";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(8, 24);
			this.textBox1.Name = "textBox1";
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "textBox1";
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(368, 24);
			this.textBox4.Name = "textBox4";
			this.textBox4.TabIndex = 4;
			this.textBox4.Text = "textBox4";
			// 
			// Select_button
			// 
			this.Select_button.Location = new System.Drawing.Point(24, 56);
			this.Select_button.Name = "Select_button";
			this.Select_button.TabIndex = 10;
			this.Select_button.Text = "Select";
			this.Select_button.Click += new System.EventHandler(this.OnSelectCommand);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(376, 56);
			this.button1.Name = "button1";
			this.button1.TabIndex = 5;
			this.button1.Text = "Browse";
			this.button1.Click += new System.EventHandler(this.OnBrowse);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(504, 16);
			this.button2.Name = "button2";
			this.button2.TabIndex = 6;
			this.button2.Text = "OK";
			this.button2.Click += new System.EventHandler(this.OnOK);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(184, 88);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(192, 23);
			this.button3.TabIndex = 8;
			this.button3.Text = "Open Database";
			this.button3.Click += new System.EventHandler(this.OnOpenDatabase);
			// 
			// listView1
			// 
			this.listView1.FullRowSelect = true;
			this.listView1.GridLines = true;
			this.listView1.Location = new System.Drawing.Point(8, 120);
			this.listView1.MultiSelect = false;
			this.listView1.Name = "listView1";
			this.listView1.Size = new System.Drawing.Size(568, 176);
			this.listView1.TabIndex = 7;
			this.listView1.View = System.Windows.Forms.View.Details;
			// 
			// Edit
			// 
			this.Edit.Location = new System.Drawing.Point(88, 304);
			this.Edit.Name = "Edit";
			this.Edit.Size = new System.Drawing.Size(72, 24);
			this.Edit.TabIndex = 9;
			this.Edit.Text = "Edit";
			this.Edit.Click += new System.EventHandler(this.OnEdit);
			// 
			// Delete
			// 
			this.Delete.Location = new System.Drawing.Point(368, 304);
			this.Delete.Name = "Delete";
			this.Delete.Size = new System.Drawing.Size(72, 24);
			this.Delete.TabIndex = 9;
			this.Delete.Text = "Delete";
			this.Delete.Click += new System.EventHandler(this.OnDelete);
			// 
			// Insert
			// 
			this.Insert.Location = new System.Drawing.Point(240, 304);
			this.Insert.Name = "Insert";
			this.Insert.Size = new System.Drawing.Size(72, 24);
			this.Insert.TabIndex = 9;
			this.Insert.Text = "Insert";
			this.Insert.Click += new System.EventHandler(this.OnInsert);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(368, 8);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(96, 16);
			this.label4.TabIndex = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -