C#winform修改access数据库中数据成功后不自动更新
stringss=null;if(clname1==txt_clname.Text.Trim()&&clgg1==txt_clgg.Text.Trim()){string...
string ss = null;
if (clname1 == txt_clname.Text.Trim() && clgg1 == txt_clgg.Text.Trim())
{
string sql = "update WlTable set [Note]='" + txt_bz.Text.Trim() + "',[Dw]=" + Convert.ToInt32(label9.Text.Trim()) + " where [clbm]=" + decimal.Parse(label3.Text.Trim()) + "";
ss = bl.add(sql111);
}
else
{
string sql = "select ClName from WlTable where ClName='" + txt_clname.Text.Trim() + "' and ClGg='" + txt_clgg.Text.Trim() + "' ";
DataTable dt = bl.selectsql(sql);
if (dt.Rows.Count >= 1)
{
MessageBox.Show("已被使用。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
string sql111 = "update WlTable set [ClName]='" + txt_clname.Text.Trim() + "',[ClGg]='" + txt_clgg.Text.Trim() + "',[Note]='" +
txt_bz.Text.Trim() + "',[Dw]=" + Convert.ToInt32(label9.Text.Trim()) + " where [clbm]=" + decimal.Parse(label3.Text.Trim()) + "";
ss = bl.add(sql111);
}
}
//timer2.Enabled = true;
string sql11 = "select a.leibie,a.ClBm,a.ClName,a.ClGg,a.Dw,b.dwname,a.Note,c.name from [WlTable] a,[dwtable] b,[ZtTable] c where a.dw=b.dwbm and a.isdelete=c.dm order by a.leibie,a.clgg";
datagridview1.DataSource = bl.selectsql(sql11);
datagridview1.RowsDefaultCellStyle.BackColor = Color.Bisque;//偶数行颜色
datagridview1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;//奇数行颜色
修改成功后不重新获取数据,点击刷新按钮后可以刷新出更新后的数据
string sql11 = "select a.leibie,a.ClBm,a.ClName,a.ClGg,a.Dw,b.dwname,a.Note,c.name from [WlTable] a,[dwtable] b,[ZtTable] c where a.dw=b.dwbm and a.isdelete=c.dm order by a.leibie,a.clgg";
datagridview1.DataSource = bl.selectsql(sql11);
datagridview1.RowsDefaultCellStyle.BackColor = Color.Bisque;//偶数行颜色
datagridview1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
这段代码就是重新获取数据 求大神指点 展开
if (clname1 == txt_clname.Text.Trim() && clgg1 == txt_clgg.Text.Trim())
{
string sql = "update WlTable set [Note]='" + txt_bz.Text.Trim() + "',[Dw]=" + Convert.ToInt32(label9.Text.Trim()) + " where [clbm]=" + decimal.Parse(label3.Text.Trim()) + "";
ss = bl.add(sql111);
}
else
{
string sql = "select ClName from WlTable where ClName='" + txt_clname.Text.Trim() + "' and ClGg='" + txt_clgg.Text.Trim() + "' ";
DataTable dt = bl.selectsql(sql);
if (dt.Rows.Count >= 1)
{
MessageBox.Show("已被使用。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
string sql111 = "update WlTable set [ClName]='" + txt_clname.Text.Trim() + "',[ClGg]='" + txt_clgg.Text.Trim() + "',[Note]='" +
txt_bz.Text.Trim() + "',[Dw]=" + Convert.ToInt32(label9.Text.Trim()) + " where [clbm]=" + decimal.Parse(label3.Text.Trim()) + "";
ss = bl.add(sql111);
}
}
//timer2.Enabled = true;
string sql11 = "select a.leibie,a.ClBm,a.ClName,a.ClGg,a.Dw,b.dwname,a.Note,c.name from [WlTable] a,[dwtable] b,[ZtTable] c where a.dw=b.dwbm and a.isdelete=c.dm order by a.leibie,a.clgg";
datagridview1.DataSource = bl.selectsql(sql11);
datagridview1.RowsDefaultCellStyle.BackColor = Color.Bisque;//偶数行颜色
datagridview1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;//奇数行颜色
修改成功后不重新获取数据,点击刷新按钮后可以刷新出更新后的数据
string sql11 = "select a.leibie,a.ClBm,a.ClName,a.ClGg,a.Dw,b.dwname,a.Note,c.name from [WlTable] a,[dwtable] b,[ZtTable] c where a.dw=b.dwbm and a.isdelete=c.dm order by a.leibie,a.clgg";
datagridview1.DataSource = bl.selectsql(sql11);
datagridview1.RowsDefaultCellStyle.BackColor = Color.Bisque;//偶数行颜色
datagridview1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
这段代码就是重新获取数据 求大神指点 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询