📄 connectionaccessdb.cs
字号:
#region 命名空间...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using WindowsApplication.EmployeeLeaveManager;
#endregion
namespace WindowsApplication.ConnectionDB
{
public class ConnectionAccessDB : WindowsApplication.EmployeeLeaveManager.ParentFrame
{
#region 控件集合...
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
private System.Data.OleDb.OleDbConnection oleDbConnection;
private WindowsApplication.ConnectionDB.oleDbAccessDBSet oleDbAccessDBSet;
private System.ComponentModel.Container components = null;
#endregion
#region 构造函数...
public ConnectionAccessDB()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ConnectionAccessDB));
this.oleDbDataAdapter = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection = new System.Data.OleDb.OleDbConnection();
this.oleDbAccessDBSet = new WindowsApplication.ConnectionDB.oleDbAccessDBSet();
((System.ComponentModel.ISupportInitialize)(this.statusZhuangTai)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusText)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.oleDbAccessDBSet)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Name = "label1";
this.label1.Text = "连接Access数据库";
//
// tool
//
this.tool.Name = "tool";
//
// status
//
this.status.Name = "status";
//
// imageList
//
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
//
// dataGrid
//
this.dataGrid.Name = "dataGrid";
//
// oleDbDataAdapter
//
this.oleDbDataAdapter.InsertCommand = this.oleDbInsertCommand1;
this.oleDbDataAdapter.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "month10", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("amorpm", "amorpm"),
new System.Data.Common.DataColumnMapping("comedate", "comedate"),
new System.Data.Common.DataColumnMapping("day", "day"),
new System.Data.Common.DataColumnMapping("name", "name")})});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT amorpm, comedate, day, name FROM month10";
this.oleDbSelectCommand1.Connection = this.oleDbConnection;
//
// oleDbInsertCommand1
//
this.oleDbInsertCommand1.CommandText = "INSERT INTO month10(amorpm, comedate, day, name) VALUES (?, ?, ?, ?)";
this.oleDbInsertCommand1.Connection = this.oleDbConnection;
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("amorpm", System.Data.OleDb.OleDbType.VarWChar, 2, "amorpm"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("comedate", System.Data.OleDb.OleDbType.DBDate, 0, "comedate"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("day", System.Data.OleDb.OleDbType.DBDate, 0, "day"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("name", System.Data.OleDb.OleDbType.VarWChar, 50, "name"));
//
// oleDbConnection
//
this.oleDbConnection.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=""C:\bgxt2\kq\2006.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;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:Global Bulk Transactions=1";
//
// oleDbAccessDBSet
//
this.oleDbAccessDBSet.DataSetName = "oleDbAccessDBSet";
this.oleDbAccessDBSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// ConnectionAccessDB
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(746, 423);
this.Name = "ConnectionAccessDB";
this.Text = "ConnectionAccessDB";
this.Load += new System.EventHandler(this.ConnectionAccessDB_Load);
((System.ComponentModel.ISupportInitialize)(this.statusZhuangTai)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusText)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.oleDbAccessDBSet)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 初始化事件...
private void ConnectionAccessDB_Load(object sender, System.EventArgs e)
{
try
{
DataTable tempTable=new DataTable();
this.oleDbDataAdapter.Fill(oleDbAccessDBSet);
tempTable=oleDbAccessDBSet.Tables[0];
base.dataGrid.DataSource=tempTable;
base.oleAdapter=this.oleDbDataAdapter;
base.dataSet=oleDbAccessDBSet;
base.cmOrders=(System.Windows.Forms.CurrencyManager) BindingContext[tempTable];
base.statusText.Text="所有记录:"+WindowsApplication.selectCount.selectCountDB.searchCount("select count(*) from month10").Trim()+"条";
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -