public partial class 挂号界面 : Form
{
OleDbConnection con = new OleDbConnection();
string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\hospital\data.accdb";
public 挂号界面()
{
InitializeComponent();
con.ConnectionString = str;
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string a = textBox1.Text;
string b = textBox2.Text;
string c = textBox3.Text;
string d = textBox4.Text;
OleDbCommand cmd = new OleDbCommand(@"insert into [patient](ID,姓名,年龄,性别) values(" + a + ",'" + b + "'," + c + ",'" + d + "')");
con.Open();
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("挂号成功!");
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
new 挂号缴费界面().ShowDialog();
}
}
}
求注册的信息中ID在数据库中已经存在,提示ID存在的代码 ,并告知添加在何处