我自己写的代码!但是我写的代码只更新了DataGridView,并没有更新库,麻烦帮解决下,附代码如下:
当点击确定按钮时执行的代码
int scount = Convert.ToInt32(this.updateCount.Text.Trim().ToString());
zcount = lcount + scount;//lcount是库中有的数量scount是增加的数量
String str = "update drugs set drugsCount="+zcount+" where drugsId="+lid;
if (da.insertDrugs(str))
{
dgvBean();
lcount = zcount;
this.updateCount.Text = "";
}
else
{
MessageBox.Show("添加失败!!!");
this.Close();
}
这个是调用的类
public Boolean changePass(string pass)
{
try
{
String sql = "update login set LoginPass='" + pass + "' where id = 1";
OleDbCommand cmd = new OleDbCommand(sql, oc);
oc.Open();
int count = Convert.ToInt32(cmd.ExecuteNonQuery().ToString());
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
finally
{
oc.Close();
} }
当点击确定按钮时执行的代码
int scount = Convert.ToInt32(this.updateCount.Text.Trim().ToString());
zcount = lcount + scount;//lcount是库中有的数量scount是增加的数量
String str = "update drugs set drugsCount="+zcount+" where drugsId="+lid;
if (da.insertDrugs(str))
{
dgvBean();
lcount = zcount;
this.updateCount.Text = "";
}
else
{
MessageBox.Show("添加失败!!!");
this.Close();
}
这个是调用的类
public Boolean changePass(string pass)
{
try
{
String sql = "update login set LoginPass='" + pass + "' where id = 1";
OleDbCommand cmd = new OleDbCommand(sql, oc);
oc.Open();
int count = Convert.ToInt32(cmd.ExecuteNonQuery().ToString());
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
finally
{
oc.Close();
} }
你可以去看看我的,大家借鉴