try
{
if(this.textBox1.Text!=""&textBox2.Text!="")
{
this.oleDbInsertCommand1.CommandText="insert into person values('"+this.textBox1.Text.Trim()+"','"+this.textBox2.Text.Trim()+"')";
this.oleDbInsertCommand1.Connection.Open();
this.oleDbInsertCommand1.ExecuteNonQuery();
this.oleDbInsertCommand1.Connection.Close();
this.dataSet11.Clear();
this.dataSet11.AcceptChanges();
MessageBox.Show("添加记录成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Question);
this.oleDbDataAdapter1.Fill(this.dataSet11);
}
else
{
MessageBox.Show("请将记录信息填写完整!","提示",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
}
catch(Exception E)
{
MessageBox.Show("添加记录发生错误:"+E.Message,"提示",MessageBoxButtons.OK,MessageBoxIcon.Question);
if(this.oleDbConnection1.State==ConnectionState.Open)
{
this.oleDbConnection1.Close();
}
}
[此贴子已经被作者于2005-12-7 10:22:35编辑过]