回复 楼主 weilight2008
我的完整代码是这样的:
程序代码:
using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
namespace officer
{
public partial class Form_luru : Form
{
public Form_luru()
{
InitializeComponent();
}
private void Form_luru_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“officerDataSet.员工信息”中。您可以根据需要移动或移除它。
//this.员工信息TableAdapter.Fill(this.officerDataSet.员工信息);
}
private void button_luru_baocun_Click(object sender, EventArgs e)
{
string xingming = this.xingming.Text;
string bianhao = this.bianhao.Text;
string xingbie = this.comboBox1.Text;
string nianyue = this.nianyue.Text;
string jiguan = this.jiguan.Text;
string mianmao = this.mianmao.Text;
string id = this.id.Text;
string school = this.school.Text;
string zhuanye = this.zhuanye.Text;
string xueli = this.xueli.Text;
string time = this.time.Text;
string hunyin = this.hunyin.Text;
string chushi = this.chushi.Text;
string shouji = this.shouji.Text;
string dianhua = this.dianhua.Text;
string email = this.email.Text;
string zhiwu = this.zhiwu.Text;
string zhicheng = this.zhicheng.Text;
string jilu = this.jilu.Text;
if (xingming == "" ||bianhao == "")
{
MessageBox.Show("带“*”部分为必填内容,请补充完整!", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
try
{
OleDbConnection officer_connection = new OleDbConnection();
officer_connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=officer.mdb";
officer_connection.Open();
// /*
OleDbCommand save_Command = officer_connection.CreateCommand();
save_ = "INSERT INTO 员工信息(姓名,员工编号,性别,出生年月,籍贯,政治面貌,身份证号,毕业院校,所学专业,最高学历,入职时间,婚姻状况,处室,手机,办公电话,邮箱,职务,职称,工作记录) VALUES('" + xingming + "','" + bianhao + "','" + xingbie + "','" +nianyue + "','" + jiguan + "','" + mianmao + "','" + id + "','" + school + "','" + zhuanye + "','" + xueli + "','" + time + "','" + hunyin + "','" + chushi + "','" +shouji + "','" +dianhua + "','" +email + "','" + zhiwu + "','" + zhicheng + "','" + jilu + "')";
save_Command.ExecuteNonQuery();
officer_connection.Close();
//*/
/*
OleDbCommand save_command = new OleDbCommand();
save_ = "INSERT INTO 员工信息(姓名,员工编号) VALUES('" + xingming + "','" + bianhao + "')";
save_command.Connection = officer_connection;
OleDbDataAdapter officer_adapeter = new OleDbDataAdapter();
officer_adapeter.SelectCommand = save_command;
officer_adapeter.Fill(officerDataSet,"员工信息");
*/
MessageBox.Show("输入成功!", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ee2)
{
MessageBox.Show(ee2.Message, "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button_luru_quxiao_Click(object sender, EventArgs e)
{
this.Close();
}
}
}