C#窗体应用程序数据写不进assess数据库
代码如下 求大神解救using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace zhuce
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String strConn = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=Student.mdb";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbCommand comm = new OleDbCommand();
try
{
if (textBox1.Text == "")
MessageBox.Show("用户名不能为空!");
else if (textBox2.Text == "")
MessageBox.Show("密码不能为空!");
else if (textBox3.Text != textBox2.Text)
MessageBox.Show("两次密码不一致!");
else if (textBox4.Text == "")
MessageBox.Show("地址不能为空!");
else if (textBox5.Text == "")
MessageBox.Show("姓名不能为空!");
else if (textBox6.Text == "")
MessageBox.Show("身份证不能为空!");
else if (textBox7.Text == "")
MessageBox.Show("手机号不能为空!");
conn.Open();
comm.Connection = conn;
string mdbtr = "INSERT INTO 表1 VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "')";
comm.ExecuteNonQuery();
conn.Close();
}
catch
{
MessageBox.Show("注册成功!");
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("注册成功!");
}
}
}