新手求教C# 更新access 数据库的问题
窗体是这样的
单击按钮代码
private void button1_Click(object sender, EventArgs e)
{
DBHelper helper = new DBHelper();
String sql1 = string.Format("select * from employee_log where [员工账号]={0} and [员工密码]={1}",all.all_emid.Trim(),textBox1.Text.Trim());
//String sql2 = string.Format("update [employee_log] set [员工密码]={0} where [员工账号]={1}",textBox1.Text.Trim(),all.all_emid.Trim());
String sql2 = "update employee_log set [员工密码]=" + textBox1.Text + " where [员工账号]=" + all.all_emid + "";
if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" || textBox3.Text.Trim() == "")
{
MessageBox.Show("密码不能为空!");
}
else if (textBox2.Text.Trim() != textBox3.Text.Trim())
{
MessageBox.Show("密码不一致,请核对.");
}
else if (helper.setS(sql1))
{
if (helper.setDS(sql2))
{
MessageBox.Show("修改成功");
}
}
else MessageBox.Show("不存在此密码.");
}
DBHelper 是个连接数据库的类
public class DBHelper
{
private OleDbConnection conn;
private OleDbDataAdapter oda = new OleDbDataAdapter();
private OleDbCommand cmd;
private DataSet myds = new DataSet();
public DBHelper()
{
conn =&