110,533
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = null;
string strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\xkzDB.mdb";
conn = new OleDbConnection(strConnection);
string sql = string.Format("insert into xkzb (Id,xklxID) values ('{0}', '{1}')", this.idTextBox.Text,this.xklxIDTextBox.Text);
OleDbCommand cmd = new OleDbCommand(sql, conn);
conn.Open();
try
{
int rowCount = cmd.ExecuteNonQuery();
if (rowCount == 1)
{
MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch
{
MessageBox.Show("添加失败!请检查是否输入数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
conn.Close();
private void button1_Click(object sender, EventArgs e)
{
DataRow drx = this.dataSet1.Tables[0].NewRow();
drx["Id"] = this.idTextBox.Text;
drx["xklxID"] = this.xklxIDTextBox.Text;
this.dataSet1.Tables[0].Rows.Add(drx);
this.xkzbTableAdapter.Update(this.dataSet1);
}