conn = Common.DBHelper.DataConn();
string sql = string.Format("insert into tb_tel([UserName],[UserSex],[UserTel]) values('{0}','{1}','{2}')", txtName.Text.Trim(), cboSex.Text, txtPhone.Text);
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
int count = cmd.ExecuteNonQuery();
if (count <= 0)
{
MessageBox.Show("添加不成功!");
}
else
{
MessageBox.Show("添加用户成功!");
txtName.Text="";
txtPhone.Text = "";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn!=null && conn.State==ConnectionState.Open)
{
conn.Close();
}
}
看不懂找我!
一下子把增删查改都问完了,就不舍得给点分数?